summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-05-22 00:53:47 (GMT)
committerGuido van Rossum <guido@python.org>1998-05-22 00:53:47 (GMT)
commit7df115de652afa918f35b1028534ed621c45160d (patch)
tree53701214098e4131bc7ea8bccf827f23b58ab16e /Modules
parent1c4f45809994fcbebd3d43ec0c771b8900e205e8 (diff)
downloadcpython-7df115de652afa918f35b1028534ed621c45160d.zip
cpython-7df115de652afa918f35b1028534ed621c45160d.tar.gz
cpython-7df115de652afa918f35b1028534ed621c45160d.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/stropmodule.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index 73c2d85..2d11851 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)) {