summaryrefslogtreecommitdiffstats
path: root/Modules/_sre.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-12-07 04:25:10 (GMT)
committerGuido van Rossum <guido@python.org>2001-12-07 04:25:10 (GMT)
commit4e173846c8688402c81d181a58b1fd787f88527a (patch)
tree6a1002b424068033e7219088cc8ac42d12662b68 /Modules/_sre.c
parent202dd1ef420359c05814cbfcc5c27e71c90c16d9 (diff)
downloadcpython-4e173846c8688402c81d181a58b1fd787f88527a.zip
cpython-4e173846c8688402c81d181a58b1fd787f88527a.tar.gz
cpython-4e173846c8688402c81d181a58b1fd787f88527a.tar.bz2
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.
Diffstat (limited to 'Modules/_sre.c')
-rw-r--r--Modules/_sre.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index c78ed52..d01f087 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -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;