diff --git a/src/base/utils/os.cpp b/src/base/utils/os.cpp index 2f1c77adb0f0..c946cb698004 100644 --- a/src/base/utils/os.cpp +++ b/src/base/utils/os.cpp @@ -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); diff --git a/src/gui/powermanagement/powermanagement.cpp b/src/gui/powermanagement/powermanagement.cpp index a51bb10fe8d9..c184dde8b63a 100644 --- a/src/gui/powermanagement/powermanagement.cpp +++ b/src/gui/powermanagement/powermanagement.cpp @@ -32,6 +32,7 @@ #ifdef Q_OS_MACOS #include +#include #endif #ifdef Q_OS_WIN @@ -74,8 +75,10 @@ void PowerManagement::setBusy() #elif defined(QBT_USES_DBUS) m_inhibitor->requestBusy(); #elif defined(Q_OS_MACOS) + const CFStringRef assertName = tr("qBittorrent is active").toCFString(); + [[maybe_unused]] const auto assertNameGuard = qScopeGuard([&assertName] { ::CFRelease(assertName); }); const IOReturn success = ::IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn - , tr("qBittorrent is active").toCFString(), &m_assertionID); + , assertName, &m_assertionID); if (success != kIOReturnSuccess) m_busy = false; #endif