Kaydet (Commit) 7df115de authored tarafından Guido van Rossum's avatar Guido van Rossum

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.
üst 1c4f4580
......@@ -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)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment