Utils: fix memory leak in normalizePathName on windows

The PIDLIST_ABSOLUTE item returned by SHParseDisplayName has to be freed
again by ILFree according to the documentation of ITEMIDLIST structure.

Change-Id: I29eb7576600287cdc8380e81a83ce2af79e13e33
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
David Schulz
2019-03-06 09:18:32 +01:00
parent ad8cabdf45
commit 1c0f83cd90

View File

@@ -311,9 +311,10 @@ QString FileUtils::normalizePathName(const QString &name)
if (FAILED(hr))
return name;
TCHAR buffer[MAX_PATH];
if (!SHGetPathFromIDList(file, buffer))
return name;
return QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const ushort *>(buffer)));
const bool success = SHGetPathFromIDList(file, buffer);
ILFree(file);
return success ? QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const ushort *>(buffer)))
: name;
#elif defined(Q_OS_OSX)
return Internal::normalizePathName(name);
#else // do not try to handle case-insensitive file systems on Linux