Commits

Andrew Kuchling  committed 5bec4a6

[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.

  • Participants
  • Parent commits 7bbff2e
  • Branches 2.4

Comments (0)

Files changed (1)

File Objects/funcobject.c

 	}
 	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");