Avoid memory leak on macOS

Only Mark-of-the-Web and Power Management are affected.

PR #22176.
This commit is contained in:
Chocobo1
2025-01-18 20:30:14 +08:00
committed by GitHub
parent 76e1040232
commit f2eecf8a4e
2 changed files with 9 additions and 2 deletions

View File

@@ -316,7 +316,11 @@ bool Utils::OS::applyMarkOfTheWeb(const Path &file, const QString &url)
::CFDictionarySetValue(properties, kLSQuarantineTypeKey, kLSQuarantineTypeOtherDownload);
if (!url.isEmpty())
::CFDictionarySetValue(properties, kLSQuarantineDataURLKey, url.toCFString());
{
const CFStringRef urlCFString = url.toCFString();
[[maybe_unused]] const auto urlStringGuard = qScopeGuard([&urlCFString] { ::CFRelease(urlCFString); });
::CFDictionarySetValue(properties, kLSQuarantineDataURLKey, urlCFString);
}
const Boolean success = ::CFURLSetResourcePropertyForKey(fileURL, kCFURLQuarantinePropertiesKey
, properties, NULL);