Fix memory leak in QStandardPaths::displayName() on Apple platforms

Task-number: QTBUG-65687
Change-Id: Ie795c8ac715e36656dabcbcdf8976d303ebaf0d1
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Jake Petroules 2018-01-11 20:24:21 -08:00
parent ab4cc83d52
commit 13c71ac816

View File

@ -248,9 +248,9 @@ QString QStandardPaths::displayName(StandardLocation type)
if (QStandardPaths::ApplicationsLocation == type)
return QCoreApplication::translate("QStandardPaths", "Applications");
const QCFString fsPath(standardLocations(type).constFirst());
if (QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
standardLocations(type).constFirst().toCFString(),
kCFURLPOSIXPathStyle, true)) {
fsPath, kCFURLPOSIXPathStyle, true)) {
QCFString name;
CFURLCopyResourcePropertyForKey(url, kCFURLLocalizedNameKey, &name, NULL);
if (name && CFStringGetLength(name))