Commit a4952141 authored by Neal Norwitz's avatar Neal Norwitz

Fix refleaks reported by Shane Hathaway in SF patch #1515361. This change

contains only the changes related to leaking the copy variable.
parent 5bdd5a90
...@@ -1237,8 +1237,10 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf, ...@@ -1237,8 +1237,10 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
importer = get_path_importer(path_importer_cache, importer = get_path_importer(path_importer_cache,
path_hooks, v); path_hooks, v);
if (importer == NULL) if (importer == NULL) {
Py_XDECREF(copy);
return NULL; return NULL;
}
/* Note: importer is a borrowed reference */ /* Note: importer is a borrowed reference */
if (importer == Py_False) { if (importer == Py_False) {
/* Cached as not being a valid dir. */ /* Cached as not being a valid dir. */
...@@ -1273,6 +1275,7 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf, ...@@ -1273,6 +1275,7 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
loader = PyObject_CallMethod(importer, loader = PyObject_CallMethod(importer,
"find_module", "find_module",
"s", fullname); "s", fullname);
Py_XDECREF(copy);
if (loader == NULL) if (loader == NULL)
return NULL; /* error */ return NULL; /* error */
if (loader != Py_None) { if (loader != Py_None) {
...@@ -1281,7 +1284,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf, ...@@ -1281,7 +1284,6 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
return &importhookdescr; return &importhookdescr;
} }
Py_DECREF(loader); Py_DECREF(loader);
Py_XDECREF(copy);
continue; continue;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment