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))
|
if (FAILED(hr))
|
||||||
return name;
|
return name;
|
||||||
TCHAR buffer[MAX_PATH];
|
TCHAR buffer[MAX_PATH];
|
||||||
if (!SHGetPathFromIDList(file, buffer))
|
const bool success = SHGetPathFromIDList(file, buffer);
|
||||||
return name;
|
ILFree(file);
|
||||||
return QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const ushort *>(buffer)));
|
return success ? QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const ushort *>(buffer)))
|
||||||
|
: name;
|
||||||
#elif defined(Q_OS_OSX)
|
#elif defined(Q_OS_OSX)
|
||||||
return Internal::normalizePathName(name);
|
return Internal::normalizePathName(name);
|
||||||
#else // do not try to handle case-insensitive file systems on Linux
|
#else // do not try to handle case-insensitive file systems on Linux
|
||||||
|
Reference in New Issue
Block a user