forked from qt-creator/qt-creator
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user