From: Andrew M. Kuchling Date: Thu, 5 Oct 2006 19:38:17 +0000 (+0000) Subject: [Backport r50681 | neal.norwitz] X-Git-Tag: v2.4.4c1~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32f378b0d925d960c3f72c0fd646c7b1b3237b5f;p=thirdparty%2FPython%2Fcpython.git [Backport r50681 | neal.norwitz] PyFunction_SetDefaults() is documented as taking None or a tuple. A NULL would crash the PyTuple_Check(). Now make NULL return a SystemError. Reported by Klocwork #73. --- diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 36c1ba86f6c5..ee373a057fdd 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -109,8 +109,8 @@ PyFunction_SetDefaults(PyObject *op, PyObject *defaults) } if (defaults == Py_None) defaults = NULL; - else if (PyTuple_Check(defaults)) { - Py_XINCREF(defaults); + else if (defaults && PyTuple_Check(defaults)) { + Py_INCREF(defaults); } else { PyErr_SetString(PyExc_SystemError, "non-tuple default args");