Fix a PIDLIST_ABSOLUTE leak in QQmlEngine on Windows
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>
Tue, 21 Oct 2014 15:12:30 +0000 (17:12 +0200)
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>
Wed, 22 Oct 2014 10:50:43 +0000 (12:50 +0200)
The documentation of SHParseDisplayName doesn't mention that you need
to free the ppidl parameter, but the documentation of the ITEMIDLIST
does mention that you need to ILFree any ITEMIDLIST passed as
PIDLIST_ABSOLUTE.

Reproduced the leak by repeatedly showing and closing the window on
the task's example.

Task-number: QTBUG-41588
Change-Id: I91d08728fc907c59e56ae344a2d12f0865031120
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/qml/qqmlengine.cpp

index 2b69661..fd8de55 100644 (file)
@@ -2305,8 +2305,12 @@ static inline QString shellNormalizeFileName(const QString &name)
         return name;
 #endif
     TCHAR buffer[MAX_PATH];
-    if (!SHGetPathFromIDList(file, buffer))
+    bool gotPath = SHGetPathFromIDList(file, buffer);
+    ILFree(file);
+
+    if (!gotPath)
         return name;
+
     QString canonicalName = QString::fromWCharArray(buffer);
     // Upper case drive letter
     if (canonicalName.size() > 2 && canonicalName.at(1) == QLatin1Char(':'))