Skip to content

Commit 8ad64aa

Browse files
committed
SF #1370197, memory leak - ast_error_finish (in error conditions).
1 parent af68c87 commit 8ad64aa

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Python/ast.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ ast_error_finish(const char *filename)
179179
return;
180180
Py_INCREF(errstr);
181181
lineno = PyInt_AsLong(PyTuple_GetItem(value, 1));
182-
if (lineno == -1)
182+
if (lineno == -1) {
183+
Py_DECREF(errstr);
183184
return;
185+
}
184186
Py_DECREF(value);
185187

186188
loc = PyErr_ProgramText(filename, lineno);
@@ -190,8 +192,10 @@ ast_error_finish(const char *filename)
190192
}
191193
tmp = Py_BuildValue("(ziOO)", filename, lineno, Py_None, loc);
192194
Py_DECREF(loc);
193-
if (!tmp)
195+
if (!tmp) {
196+
Py_DECREF(errstr);
194197
return;
198+
}
195199
value = Py_BuildValue("(OO)", errstr, tmp);
196200
Py_DECREF(errstr);
197201
Py_DECREF(tmp);

0 commit comments

Comments
 (0)