From efde4c99dae1a3ad56610e05d3a23b195060041e Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 24 Nov 2019 16:36:24 +0000 Subject: [PATCH] *.c: Be more careful about `PySequence_Size'. This can be implemented by Python, so it can throw exceptions. Fortunately, Python checks that the result is nonnegative, so we don't have to worry about that. --- catacomb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/catacomb.c b/catacomb.c index edb0c4a..d82ed7c 100644 --- a/catacomb.c +++ b/catacomb.c @@ -76,7 +76,8 @@ PyObject *mexp_common(PyObject *me, PyObject *arg, arg = PyTuple_GetItem(arg, 0); Py_INCREF(arg); if (!PySequence_Check(arg)) TYERR("not a sequence"); - n = PySequence_Size(arg); if (!n) { z = id(me); goto end; } + n = PySequence_Size(arg); if (n < 0) goto end; + if (!n) { z = id(me); goto end; } x = PySequence_GetItem(arg, 0); if (PySequence_Check(x)) flat = 0; -- 2.11.0