Commits

Bob Ippolito committed b71524c

Fix nil dereference bug in OC_NSBundleHack

  • Participants
  • Parent commits 0a06dd1
  • Branches pyobjc-ancient

Comments (0)

Files changed (3)

File Modules/objc/OC_NSBundleHack.m

 	NULL, // no need to retain classes
 	NULL, // no need to release classes
 	NULL, // generic description
-	NULL // not a key
+	NULL  // not a key
 };
 
 static
 {
 	static NSBundle* mainBundle = nil;
 	static NSMapTable* bundleCache = nil;
-	if (!mainBundle) mainBundle = [[NSBundle mainBundle] retain];
-	if (!bundleCache) bundleCache = NSCreateMapTable(PyObjC_ClassToNSBundleTable_KeyCallBacks, PyObjC_ClassToNSBundle_ValueCallBacks, PYOBJC_EXPECTED_CLASS_COUNT);
+	if (!mainBundle) {
+		mainBundle = [[NSBundle mainBundle] retain];
+	}
+	if (!bundleCache) {
+		bundleCache = NSCreateMapTable(PyObjC_ClassToNSBundleTable_KeyCallBacks, PyObjC_ClassToNSBundle_ValueCallBacks, PYOBJC_EXPECTED_CLASS_COUNT);
+	}
+	if (!aClass) {
+		return mainBundle;
+	}
 	id rval = (id)NSMapGet(bundleCache, (const void *)aClass);
 	if (rval) {
 		return rval;
 <p>An overview of the relevant changes in new, and older, releases.</p>
 <h2><a name="version-1-3-1-2005-04">Version 1.3.1 (2005-04-??)</a></h2>
 <ul>
+<li>Fixed bug in the NSBundle hack that caused a NULL pointer to be
+dereferenced if looking up a non-existent class using NSBundle API.</li>
 <li>Added <code><span>OC_PythonUnicode</span></code> and <code><span>OC_PythonString</span></code> classes that
 preserve the identity of <code><span>str</span></code> and <code><span>unicode</span></code> objects across
 the bridge.  Additionally, bridge for <code><span>str</span></code> now uses the default
 Version 1.3.1 (2005-04-??)
 --------------------------
 
+- Fixed bug in the NSBundle hack that caused a NULL pointer to be
+  dereferenced if looking up a non-existent class using NSBundle API.
+
 - Added ``OC_PythonUnicode`` and ``OC_PythonString`` classes that
   preserve the identity of ``str`` and ``unicode`` objects across
   the bridge.  Additionally, bridge for ``str`` now uses the default