Commit bbf892e3 authored by Guido van Rossum's avatar Guido van Rossum

Fix for #489672 (Neil Norwitz): memory leak in test_sre.

(At least for the repeatable test case that Tim produced.)

pattern_subx(): Add missing DECREF(filter) in both exit branches
(normal and error return).  Also fix a DECREF(args) that should
certainly be a DECREF(match) -- because it's inside if (!args) and
right after allocation of match.
parent f284538b
......@@ -2199,7 +2199,7 @@ pattern_subx(PatternObject* self, PyObject* template, PyObject* string,
goto error;
args = Py_BuildValue("(O)", match);
if (!args) {
Py_DECREF(args);
Py_DECREF(match);
goto error;
}
item = PyObject_CallObject(filter, args);
......@@ -2246,6 +2246,8 @@ next:
state_fini(&state);
Py_DECREF(filter);
/* convert list to single string (also removes list) */
item = join(list, self->pattern);
......@@ -2258,6 +2260,7 @@ next:
return item;
error:
Py_DECREF(filter);
Py_DECREF(list);
state_fini(&state);
return NULL;
......
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