From 156fe3ccca47d40808328dcecb45b444be2ec627 Mon Sep 17 00:00:00 2001 From: das Date: Mon, 5 Oct 2009 02:41:17 +0000 Subject: * macosx/tclMacOSXBundle.c: Workaround CF memory managment bug in * unix/tclUnixInit.c: Mac OS X 10.4 & earlier. [Bug 2569449] --- ChangeLog | 5 +++++ macosx/tclMacOSXBundle.c | 33 ++++++++++++++++++++++----------- unix/tclUnixInit.c | 11 ++++++----- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7bd1f8e..a1a2ef0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-10-04 Daniel Steffen + + * macosx/tclMacOSXBundle.c: Workaround CF memory managment bug in + * unix/tclUnixInit.c: Mac OS X 10.4 & earlier. [Bug 2569449] + 2009-09-28 Don Porter * generic/tclAlloc.c: Cleaned up various routines in the diff --git a/macosx/tclMacOSXBundle.c b/macosx/tclMacOSXBundle.c index af047d2..ef87dbf 100644 --- a/macosx/tclMacOSXBundle.c +++ b/macosx/tclMacOSXBundle.c @@ -5,7 +5,7 @@ * MacOS X. * * Copyright 2001, Apple Computer, Inc. - * Copyright (c) 2003-2007 Daniel A. Steffen + * Copyright (c) 2003-2009 Daniel A. Steffen * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. @@ -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.3.2.7 2008/12/07 16:39:56 das Exp $ + * RCS: @(#) $Id: tclMacOSXBundle.c,v 1.3.2.8 2009/10/05 02:41:18 das Exp $ */ #include "tclPort.h" @@ -56,6 +56,11 @@ #ifdef HAVE_COREFOUNDATION #include #include + +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +MODULE_SCOPE long tclMacOSXDarwinRelease; +#endif + #endif /* HAVE_COREFOUNDATION */ /* @@ -145,17 +150,16 @@ Tcl_MacOSXOpenVersionedBundleResources( bundleVersion, kCFStringEncodingUTF8); if (bundleVersionRef) { + CFComparisonResult versionComparison = kCFCompareLessThan; CFStringRef bundleTailRef = CFURLCopyLastPathComponent( bundleURL); if (bundleTailRef) { - if (CFStringCompare(bundleTailRef, bundleVersionRef, 0) == - kCFCompareEqualTo) { - versionedBundleRef = (CFBundleRef) CFRetain(bundleRef); - } + versionComparison = CFStringCompare(bundleTailRef, + bundleVersionRef, 0); CFRelease(bundleTailRef); } - if (!versionedBundleRef) { + if (versionComparison != kCFCompareEqualTo) { CFURLRef versURL = CFURLCreateCopyAppendingPathComponent( NULL, bundleURL, CFSTR("Versions"), TRUE); @@ -163,9 +167,13 @@ Tcl_MacOSXOpenVersionedBundleResources( CFURLRef versionedBundleURL = CFURLCreateCopyAppendingPathComponent( NULL, versURL, bundleVersionRef, TRUE); + if (versionedBundleURL) { versionedBundleRef = CFBundleCreate(NULL, versionedBundleURL); + if (versionedBundleRef) { + bundleRef = versionedBundleRef; + } CFRelease(versionedBundleURL); } CFRelease(versURL); @@ -175,9 +183,6 @@ Tcl_MacOSXOpenVersionedBundleResources( } CFRelease(bundleURL); } - if (versionedBundleRef) { - bundleRef = versionedBundleRef; - } } if (bundleRef) { @@ -225,7 +230,13 @@ Tcl_MacOSXOpenVersionedBundleResources( CFRelease(libURL); } if (versionedBundleRef) { - CFRelease(versionedBundleRef); +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 + /* Workaround CFBundle bug in Tiger and earlier. [Bug 2569449] */ + if (tclMacOSXDarwinRelease >= 9) +#endif + { + CFRelease(versionedBundleRef); + } } } diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 795d312..f2918d7 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -7,7 +7,7 @@ * Copyright (c) 1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tclUnixInit.c,v 1.34.2.15 2007/04/29 02:19:51 das Exp $ + * RCS: @(#) $Id: tclUnixInit.c,v 1.34.2.16 2009/10/05 02:41:18 das Exp $ */ #if defined(HAVE_COREFOUNDATION) @@ -159,10 +159,11 @@ static int MacOSXGetLibraryPath _ANSI_ARGS_(( char *tclLibPath)); #endif /* HAVE_COREFOUNDATION */ #if defined(__APPLE__) && (defined(TCL_LOAD_FROM_MEMORY) || ( \ - defined(TCL_THREADS) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \ - MAC_OS_X_VERSION_MIN_REQUIRED < 1030) || ( \ - defined(__LP64__) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \ - MAC_OS_X_VERSION_MIN_REQUIRED < 1050)) + defined(MAC_OS_X_VERSION_MIN_REQUIRED) && ( \ + (defined(TCL_THREADS) && MAC_OS_X_VERSION_MIN_REQUIRED < 1030) || \ + (defined(__LP64__) && MAC_OS_X_VERSION_MIN_REQUIRED < 1050) || \ + (defined(HAVE_COREFOUNDATION) && MAC_OS_X_VERSION_MIN_REQUIRED < 1050)\ + ))) /* * Need to check Darwin release at runtime in tclUnixFCmd.c and tclLoadDyld.c: * initialize release global at startup from uname(). -- cgit v0.12