From dd6876f3fdeb4b95a24fba4ad48cbf445b8fb9f4 Mon Sep 17 00:00:00 2001
From: Dyami Caliri <dyami@dragonframe.com>
Date: Wed, 29 Oct 2014 14:10:05 -0700
Subject: [PATCH] QCocoaPrintDevice: fix bad CFRelease

CFRelease should be called IFF PMPrinterCopyDescriptionURL succeeds

Change-Id: Id289aea3a4e3da397dae4062319256a043538597
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
---
 src/plugins/platforms/cocoa/qcocoaprintdevice.mm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
index b3551e2c29a..c26a2b22fdc 100644
--- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
+++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
@@ -468,11 +468,11 @@ bool QCocoaPrintDevice::openPpdFile()
     CFURLRef ppdURL = NULL;
     char ppdPath[MAXPATHLEN];
     if (PMPrinterCopyDescriptionURL(m_printer, kPMPPDDescriptionType, &ppdURL) == noErr
-        && ppdURL != NULL
-        && CFURLGetFileSystemRepresentation(ppdURL, true, (UInt8*)ppdPath, sizeof(ppdPath))) {
-        m_ppd = ppdOpenFile(ppdPath);
+        && ppdURL != NULL) {
+        if (CFURLGetFileSystemRepresentation(ppdURL, true, (UInt8*)ppdPath, sizeof(ppdPath)))
+            m_ppd = ppdOpenFile(ppdPath);
+        CFRelease(ppdURL);
     }
-    CFRelease(ppdURL);
     return m_ppd ? true : false;
 }
 
-- 
GitLab