Skip to content
  • Jonathan Marten's avatar
    Avoid possible null pointer dereference in WebEnginePartDownloadManager::blobDownloadedToFile() · af216b7b
    Jonathan Marten authored and Stefano Crocco's avatar Stefano Crocco committed
    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
    with:
    
    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.
    af216b7b