From: Guido van Rossum Date: Fri, 22 May 1998 00:53:47 +0000 (+0000) Subject: Make sure that no use of a function pointer gotten from a X-Git-Tag: v1.5.2a1~568 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7df115de652afa918f35b1028534ed621c45160d;p=thirdparty%2FPython%2Fcpython.git Make sure that no use of a function pointer gotten from a tp_as_sequence or tp_as_mapping structure is made without checking it for NULL first. --- diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index 73c2d8568324..2d11851e7c07 100644 --- a/Modules/stropmodule.c +++ b/Modules/stropmodule.c @@ -274,13 +274,15 @@ strop_joinfields(self, args) } return res; } - else if (!PySequence_Check(seq)) { + + if (seq->ob_type->tp_as_sequence == NULL || + (getitemfunc = seq->ob_type->tp_as_sequence->sq_item) == NULL) + { PyErr_SetString(PyExc_TypeError, "first argument must be a sequence"); return NULL; } - /* type safe */ - getitemfunc = seq->ob_type->tp_as_sequence->sq_item; + /* This is now type safe */ for (i = 0; i < seqlen; i++) { PyObject *item = getitemfunc(seq, i); if (!item || !PyString_Check(item)) {