Details
Description
In certain cases calling QWebView::setUrl(QUrl("file:///<directory>")) causes Qt to crash.
When QWebView::setUrl() is called on a local text file, followed by a call to setUrl() specifying a local file that happens to be a directory, the entire Qt application crashes.
For example, the following sequence of calls will crash Qt:
QWebView wv;
wv.setUrl(QUrl("file:///C:/Windows/win.ini"));
wv.setUrl(QUrl("file:///C:/Windows"));
wv.show();
Assuming that C:/Windows/win.ini and C:/Windows exist. Interestingly enough if the setUrl("...win.ini") call is missing the application does not crash.
A temporary workaround for users of Qt is to never call setUrl() on a directory. In the long term Qt should not crash on this input.
The following errors were detected in the QtCreator application output:
Starting D:\code\build-seturl-crash-test-case-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\seturl-crash-test-case...
QIODevice::read: maxSize argument exceeds QByteArray size limit
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
LEAK: 3 RenderObject
LEAK: 1 Page
LEAK: 1 Frame
LEAK: 4 WebCoreNode
D:\code\build-seturl-crash-test-case-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\seturl-crash-test-case exited with code 3
This crash only happens when running the application inside Qt Creator with <CTRL>-R. It does not happen when running it in the debugger using <F5>.
The crash symptom on Windows is that an error dialog shows up, followed by a force quit. Screenshots of both are attached to this ticket.
I was unfortunately unable to obtain a stack trace.