From 5da2576633bc0d0150a8607a30ab1f66f040bb19 Mon Sep 17 00:00:00 2001 From: Robin KAY Date: Tue, 24 Jun 2014 23:35:22 +0100 Subject: [PATCH] Fix intermittent crash with older MinGW releases 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 --- src/qml/qml/qqmlengine.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 0424c57..70d0c3a 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -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(&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(':')) -- 2.7.4