]> granicus.if.org Git - python/commitdiff
Fix refleaks reported by Shane Hathaway in SF patch #1515361. This change
authorNeal Norwitz <nnorwitz@gmail.com>
Thu, 6 Jul 2006 04:28:59 +0000 (04:28 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Thu, 6 Jul 2006 04:28:59 +0000 (04:28 +0000)
contains only the changes related to leaking the copy variable.

Python/import.c

index c49a91fc6a6ba02bbca83f9ac3daba604a5978a1..933f094e7d8d29f1e9f7f78ca15186771f91348c 100644 (file)
@@ -1237,8 +1237,10 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
 
                        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 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
                                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 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
                                        return &importhookdescr;
                                }
                                Py_DECREF(loader);
-                               Py_XDECREF(copy);
                                continue;
                        }
                }