[Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.196,2.197
Tim Peters
tim_one@users.sourceforge.net
Sat, 07 Apr 2001 13:34:51 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv19312/python/dist/src/Python
Modified Files:
bltinmodule.c
Log Message:
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.
Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.196
retrieving revision 2.197
diff -C2 -r2.196 -r2.197
*** bltinmodule.c 2001/03/22 02:47:58 2.196
--- bltinmodule.c 2001/04/07 20:34:48 2.197
***************
*** 2292,2302 ****
goto Fail_1;
arg = Py_BuildValue("(O)", item);
! Py_DECREF(item);
! if (arg == NULL)
goto Fail_1;
good = PyEval_CallObject(func, arg);
Py_DECREF(arg);
! if (good == NULL)
goto Fail_1;
ok = PyObject_IsTrue(good);
Py_DECREF(good);
--- 2292,2305 ----
goto Fail_1;
arg = Py_BuildValue("(O)", item);
! if (arg == NULL) {
! Py_DECREF(item);
goto Fail_1;
+ }
good = PyEval_CallObject(func, arg);
Py_DECREF(arg);
! if (good == NULL) {
! Py_DECREF(item);
goto Fail_1;
+ }
ok = PyObject_IsTrue(good);
Py_DECREF(good);
***************
*** 2304,2307 ****
--- 2307,2311 ----
PyString_AS_STRING((PyStringObject *)result)[j++] =
PyString_AS_STRING((PyStringObject *)item)[0];
+ Py_DECREF(item);
}