summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authordas <das>2008-12-07 16:28:44 (GMT)
committerdas <das>2008-12-07 16:28:44 (GMT)
commit60065d3056a7581a4479d0a0aed5fe461a674098 (patch)
treec6e3fb6407dbf55371ff09835a240de992652bf9 /macosx
parent0b24fb67d14cb4d0ddbf252eb14f5d4c6a9485e7 (diff)
downloadtcl-60065d3056a7581a4479d0a0aed5fe461a674098.zip
tcl-60065d3056a7581a4479d0a0aed5fe461a674098.tar.gz
tcl-60065d3056a7581a4479d0a0aed5fe461a674098.tar.bz2
Tcl_MacOSXOpenVersionedBundleResources: Fix leak, simplify logic
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tclMacOSXBundle.c64
1 files changed, 36 insertions, 28 deletions
diff --git a/macosx/tclMacOSXBundle.c b/macosx/tclMacOSXBundle.c
index 6b0b6f7..14be2f0 100644
--- a/macosx/tclMacOSXBundle.c
+++ b/macosx/tclMacOSXBundle.c
@@ -48,7 +48,7 @@
* permission to use and distribute the software in accordance with the
* terms specified in this license.
*
- * RCS: @(#) $Id: tclMacOSXBundle.c,v 1.12 2008/04/27 22:21:33 dkf Exp $
+ * RCS: @(#) $Id: tclMacOSXBundle.c,v 1.13 2008/12/07 16:28:44 das Exp $
*/
#include "tclPort.h"
@@ -121,7 +121,7 @@ Tcl_MacOSXOpenVersionedBundleResources(
char *libraryPath)
{
#ifdef HAVE_COREFOUNDATION
- CFBundleRef bundleRef;
+ CFBundleRef bundleRef, versionedBundleRef = NULL;
CFStringRef bundleNameRef;
CFURLRef libURL;
@@ -138,41 +138,46 @@ Tcl_MacOSXOpenVersionedBundleResources(
* Create bundle from bundleVersion subdirectory of 'Versions'.
*/
- CFBundleRef versionedBundleRef = NULL;
- CFURLRef versionedBundleURL = NULL;
- CFStringRef bundleVersionRef = CFStringCreateWithCString(NULL,
- bundleVersion, kCFStringEncodingUTF8);
CFURLRef bundleURL = CFBundleCopyBundleURL(bundleRef);
if (bundleURL) {
- CFStringRef bundleTailRef = CFURLCopyLastPathComponent(bundleURL);
+ CFStringRef bundleVersionRef = CFStringCreateWithCString(NULL,
+ bundleVersion, kCFStringEncodingUTF8);
- if (bundleTailRef) {
- if (CFStringCompare(bundleTailRef, bundleVersionRef, 0) ==
- kCFCompareEqualTo) {
- versionedBundleRef = bundleRef;
- }
- CFRelease(bundleTailRef);
- }
- }
+ if (bundleVersionRef) {
+ CFStringRef bundleTailRef = CFURLCopyLastPathComponent(
+ bundleURL);
- if (bundleURL && !versionedBundleRef) {
- CFURLRef versURL = CFURLCreateCopyAppendingPathComponent(NULL,
- bundleURL, CFSTR("Versions"), TRUE);
-
- if (versURL) {
- versionedBundleURL = CFURLCreateCopyAppendingPathComponent(
- NULL, versURL, bundleVersionRef, TRUE);
- CFRelease(versURL);
+ if (bundleTailRef) {
+ if (CFStringCompare(bundleTailRef, bundleVersionRef, 0) ==
+ kCFCompareEqualTo) {
+ versionedBundleRef = (CFBundleRef) CFRetain(bundleRef);
+ }
+ CFRelease(bundleTailRef);
+ }
+ if (!versionedBundleRef) {
+ CFURLRef versURL = CFURLCreateCopyAppendingPathComponent(
+ NULL, bundleURL, CFSTR("Versions"), TRUE);
+
+ if (versURL) {
+ CFURLRef versionedBundleURL =
+ CFURLCreateCopyAppendingPathComponent(
+ NULL, versURL, bundleVersionRef, TRUE);
+ if (versionedBundleURL) {
+ versionedBundleRef = CFBundleCreate(NULL,
+ versionedBundleURL);
+ CFRelease(versionedBundleURL);
+ }
+ CFRelease(versURL);
+ }
+ }
+ CFRelease(bundleVersionRef);
}
CFRelease(bundleURL);
}
- CFRelease(bundleVersionRef);
- if (versionedBundleURL) {
- versionedBundleRef = CFBundleCreate(NULL, versionedBundleURL);
- CFRelease(versionedBundleURL);
+ if (versionedBundleRef) {
+ bundleRef = versionedBundleRef;
}
- bundleRef = versionedBundleRef;
}
if (bundleRef) {
@@ -219,6 +224,9 @@ Tcl_MacOSXOpenVersionedBundleResources(
(unsigned char*) libraryPath, maxPathLen);
CFRelease(libURL);
}
+ if (versionedBundleRef) {
+ CFRelease(versionedBundleRef);
+ }
}
if (libraryPath[0]) {