Commit af216b7b authored by Jonathan Marten's avatar Jonathan Marten Committed by Stefano Crocco
Browse files

Avoid possible null pointer dereference in WebEnginePartDownloadManager::blobDownloadedToFile()

In the 'else' block, the 'page' pointer must be null because a non-null
pointer is handled in the 'if' part.  If this block were to be executed,
there would be a null dereference through the pointer.  GCC detects this

webenginepart/src/webenginepartdownloadmanager.cpp: In member function
  'void WebEnginePartDownloadManager::blobDownloadedToFile(QWebEngineDownloadItem*, WebEnginePage*)':
webenginepart/src/webenginepartdownloadmanager.cpp:177: warning: 'this' pointer is null
/usr/include/qt5/QtWebEngineWidgets/qwebenginepage.h:244: note: in a call to non-static
  member function 'QWidget* QWebEnginePage::view() const'

Since 'w' can never be a valid widget, the solution is simply to pass
nullptr to the JobUiIDelegate.
parent ff5d40cc
Pipeline #173471 passed with stage
in 7 minutes and 50 seconds
......@@ -174,8 +174,7 @@ void WebEnginePartDownloadManager::blobDownloadedToFile(QWebEngineDownloadItem *
page->requestOpenFileAsTemporary(QUrl::fromLocalFile(file), it->mimeType());
} else {
KIO::OpenUrlJob *j = new KIO::OpenUrlJob(QUrl::fromLocalFile(file), it->mimeType(), this);
QWidget *w = page->view();
j->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, w ? w->window() : nullptr));
j->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, nullptr));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment