]> granicus.if.org Git - python/commitdiff
SF #1370197, memory leak - ast_error_finish (in error conditions).
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 11 Dec 2005 20:08:33 +0000 (20:08 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 11 Dec 2005 20:08:33 +0000 (20:08 +0000)
Python/ast.c

index 2250683a3db9e86c33dbb8b09db0d3f719c53c8d..89ec2178f2468ff4aeabd5e2730254ba721456f7 100644 (file)
@@ -179,8 +179,10 @@ ast_error_finish(const char *filename)
        return;
     Py_INCREF(errstr);
     lineno = PyInt_AsLong(PyTuple_GetItem(value, 1));
-    if (lineno == -1)
+    if (lineno == -1) {
+       Py_DECREF(errstr);
        return;
+    }
     Py_DECREF(value);
 
     loc = PyErr_ProgramText(filename, lineno);
@@ -190,8 +192,10 @@ ast_error_finish(const char *filename)
     }
     tmp = Py_BuildValue("(ziOO)", filename, lineno, Py_None, loc);
     Py_DECREF(loc);
-    if (!tmp)
+    if (!tmp) {
+       Py_DECREF(errstr);
        return;
+    }
     value = Py_BuildValue("(OO)", errstr, tmp);
     Py_DECREF(errstr);
     Py_DECREF(tmp);