summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-04-07 20:34:48 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-04-07 20:34:48 (GMT)
commit388ed08cbf89ec362541bb165045739866fe9c98 (patch)
treedb1f25a77e655c0334a9fd12969fafbce7c389bf /Python/bltinmodule.c
parent4d4d0034c0987313ef96fd085f1fd616d96ab4ad (diff)
downloadcpython-388ed08cbf89ec362541bb165045739866fe9c98.zip
cpython-388ed08cbf89ec362541bb165045739866fe9c98.tar.gz
cpython-388ed08cbf89ec362541bb165045739866fe9c98.tar.bz2
SF patch #413552 - Premature decref on object
Jeffery Collins pointed out that filterstring decrefs a character object before it's done using it. This works by accident today because another module always happens to have an active reference too at the time. The accident doesn't work after his Pippy modifications, and since it *is* an accident even in the mainline Python, it should work by design there too. The patch accomplishes that.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 9a09c8c..576447c 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -2291,18 +2291,22 @@ filterstring(PyObject *func, PyObject *strobj)
if (item == NULL)
goto Fail_1;
arg = Py_BuildValue("(O)", item);
- Py_DECREF(item);
- if (arg == NULL)
+ if (arg == NULL) {
+ Py_DECREF(item);
goto Fail_1;
+ }
good = PyEval_CallObject(func, arg);
Py_DECREF(arg);
- if (good == NULL)
+ if (good == NULL) {
+ Py_DECREF(item);
goto Fail_1;
+ }
ok = PyObject_IsTrue(good);
Py_DECREF(good);
if (ok)
PyString_AS_STRING((PyStringObject *)result)[j++] =
PyString_AS_STRING((PyStringObject *)item)[0];
+ Py_DECREF(item);
}
if (j < len && _PyString_Resize(&result, j) < 0)