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.
This commit is contained in:
Neal Norwitz 2006-07-16 02:35:47 +00:00
parent fc28e0de58
commit ee4cc698ca
1 changed files with 2 additions and 2 deletions

View File

@ -109,8 +109,8 @@ PyFunction_SetDefaults(PyObject *op, PyObject *defaults)
} }
if (defaults == Py_None) if (defaults == Py_None)
defaults = NULL; defaults = NULL;
else if (PyTuple_Check(defaults)) { else if (defaults && PyTuple_Check(defaults)) {
Py_XINCREF(defaults); Py_INCREF(defaults);
} }
else { else {
PyErr_SetString(PyExc_SystemError, "non-tuple default args"); PyErr_SetString(PyExc_SystemError, "non-tuple default args");