[Python-checkins] r47251 - python/trunk/Python/import.c

neal.norwitz python-checkins at python.org
Thu Jul 6 06:29:04 CEST 2006


Author: neal.norwitz
Date: Thu Jul  6 06:28:59 2006
New Revision: 47251

Modified:
   python/trunk/Python/import.c
Log:
Fix refleaks reported by Shane Hathaway in SF patch #1515361.  This change
contains only the changes related to leaking the copy variable.


Modified: python/trunk/Python/import.c
==============================================================================
--- python/trunk/Python/import.c	(original)
+++ python/trunk/Python/import.c	Thu Jul  6 06:28:59 2006
@@ -1237,8 +1237,10 @@
 
 			importer = get_path_importer(path_importer_cache,
 						     path_hooks, v);
-			if (importer == NULL)
+			if (importer == NULL) {
+				Py_XDECREF(copy);
 				return NULL;
+			}
 			/* Note: importer is a borrowed reference */
 			if (importer == Py_False) {
 				/* Cached as not being a valid dir. */
@@ -1273,6 +1275,7 @@
 				loader = PyObject_CallMethod(importer,
 							     "find_module",
 							     "s", fullname);
+				Py_XDECREF(copy);
 				if (loader == NULL)
 					return NULL;  /* error */
 				if (loader != Py_None) {
@@ -1281,7 +1284,6 @@
 					return &importhookdescr;
 				}
 				Py_DECREF(loader);
-				Py_XDECREF(copy);
 				continue;
 			}
 		}


More information about the Python-checkins mailing list