]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix refleak
authorBenjamin Peterson <benjamin@python.org>
Sat, 16 Oct 2010 03:12:39 +0000 (03:12 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sat, 16 Oct 2010 03:12:39 +0000 (03:12 +0000)
Python/import.c

index 94363deae0215dc901023e643d8b7e0ada5fe551..5a09c9759c49ba70e5d7dec3108e2cd2d24a467e 100644 (file)
@@ -3462,7 +3462,7 @@ imp_cache_from_source(PyObject *self, PyObject *args, PyObject *kws)
     char buf[MAXPATHLEN+1];
     PyObject *pathbytes;
     char *cpathname;
-    PyObject *debug_override = Py_None;
+    PyObject *debug_override = NULL;
     int debug = !Py_OptimizeFlag;
 
     if (!PyArg_ParseTupleAndKeywords(
@@ -3470,9 +3470,11 @@ imp_cache_from_source(PyObject *self, PyObject *args, PyObject *kws)
                 PyUnicode_FSConverter, &pathbytes, &debug_override))
         return NULL;
 
-    if (debug_override != Py_None)
-        if ((debug = PyObject_IsTrue(debug_override)) < 0)
-            return NULL;
+    if (debug_override != NULL &&
+        (debug = PyObject_IsTrue(debug_override)) < 0) {
+        Py_DECREF(pathbytes);
+        return NULL;
+    }
 
     cpathname = make_compiled_pathname(
         PyBytes_AS_STRING(pathbytes),