Fix intermittent crash with older MinGW releases
authorRobin KAY <komadori@gekkou.co.uk>
Tue, 24 Jun 2014 22:35:22 +0000 (23:35 +0100)
committerRobin KAY <komadori@gekkou.co.uk>
Fri, 27 Jun 2014 19:11:30 +0000 (21:11 +0200)
An alternate code-path was previously added to work around a bad
signature for the SHParseDisplayName() function in older and non-w64
versions of the MinGW headers. This code-path incorrectly passed a
single rather double indirect pointer to the third argument of that
function causing it to produce corrupt data and subsequently crash.
This change modifies the code to instead cast a pointer of the correct
type to the incorrect type expected by the headers.

Task-number: QTBUG-39793
Change-Id: I4d65dea4fc38d7e885468cd23434d8570c311fc2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
src/qml/qml/qqmlengine.cpp

index 0424c57..70d0c3a 100644 (file)
@@ -2306,20 +2306,17 @@ static inline QString shellNormalizeFileName(const QString &name)
 // The correct declaration of the SHGetPathFromIDList symbol is
 // being used in mingw-w64 as of r6215, which is a v3 snapshot.
 #if defined(Q_CC_MINGW) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3)
-    ITEMIDLIST file;
-    if (FAILED(SHParseDisplayName(nameC, NULL, &file, 0, NULL)))
-        return name;
-    TCHAR buffer[MAX_PATH];
-    if (!SHGetPathFromIDList(&file, buffer))
+    ITEMIDLIST *file;
+    if (FAILED(SHParseDisplayName(nameC, NULL, reinterpret_cast<LPITEMIDLIST>(&file), 0, NULL)))
         return name;
 #else
     PIDLIST_ABSOLUTE file;
     if (FAILED(SHParseDisplayName(nameC, NULL, &file, 0, NULL)))
         return name;
+#endif
     TCHAR buffer[MAX_PATH];
     if (!SHGetPathFromIDList(file, buffer))
         return name;
-#endif
     QString canonicalName = QString::fromWCharArray(buffer);
     // Upper case drive letter
     if (canonicalName.size() > 2 && canonicalName.at(1) == QLatin1Char(':'))