diff options
author | David Schulz <david.schulz@qt.io> | 2019-03-06 09:18:32 +0100 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2019-03-06 08:47:20 +0000 |
commit | 1c0f83cd90dac9c384099f7ffd311d03e880bcf4 (patch) | |
tree | 1e1fa0f51e5b1896ddcb47887e6d56f00287b610 /src/libs/utils | |
parent | ad8cabdf45143423717513778afcbd2e4485a685 (diff) |
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>
Diffstat (limited to 'src/libs/utils')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 708595aa4d..a476cd8d89 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -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 |