summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2005-07-12 10:21:19 (GMT)
committerMichael W. Hudson <mwh@python.net>2005-07-12 10:21:19 (GMT)
commit0edc7a03e2505c4e9b3186f8b6caa18a7b3988e2 (patch)
treec192e6bf89c8bcbcdd869a01bbec4cc3981a1f6a /Objects
parent208eec2cad5dcfdd7fe2c8fa706ec5e89533c87d (diff)
downloadcpython-0edc7a03e2505c4e9b3186f8b6caa18a7b3988e2.zip
cpython-0edc7a03e2505c4e9b3186f8b6caa18a7b3988e2.tar.gz
cpython-0edc7a03e2505c4e9b3186f8b6caa18a7b3988e2.tar.bz2
Fix:
[ 1229429 ] missing Py_DECREF in PyObject_CallMethod Add a test in test_enumerate, which is a bit random, but suffices (reversed_new calls PyObject_CallMethod under some circumstances).
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index d28006a..cade2aa 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1797,7 +1797,9 @@ PyObject *
PyObject_CallMethod(PyObject *o, char *name, char *format, ...)
{
va_list va;
- PyObject *args, *func = 0, *retval;
+ PyObject *args = NULL;
+ PyObject *func = NULL;
+ PyObject *retval = NULL;
if (o == NULL || name == NULL)
return null_error();
@@ -1808,8 +1810,10 @@ PyObject_CallMethod(PyObject *o, char *name, char *format, ...)
return 0;
}
- if (!PyCallable_Check(func))
- return type_error("call of non-callable attribute");
+ if (!PyCallable_Check(func)) {
+ type_error("call of non-callable attribute");
+ goto exit;
+ }
if (format && *format) {
va_start(va, format);
@@ -1820,23 +1824,24 @@ PyObject_CallMethod(PyObject *o, char *name, char *format, ...)
args = PyTuple_New(0);
if (!args)
- return NULL;
+ goto exit;
if (!PyTuple_Check(args)) {
PyObject *a;
a = PyTuple_New(1);
if (a == NULL)
- return NULL;
+ goto exit;
if (PyTuple_SetItem(a, 0, args) < 0)
- return NULL;
+ goto exit;
args = a;
}
retval = PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- Py_DECREF(func);
+ exit:
+ Py_XDECREF(args);
+ Py_XDECREF(func);
return retval;
}