chiark
/
gitweb
/
~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
*.c: Be more careful about `PySequence_Size'.
[catacomb-python]
/
mp.c
diff --git
a/mp.c
b/mp.c
index f2a00b996047ae91d7ba20a794dfcb5f325cf04c..ab15d3fd10e115c476f1623e1eb162c37bb1d68f 100644
(file)
--- a/
mp.c
+++ b/
mp.c
@@
-1689,7
+1689,8
@@
static PyObject *mcmeth_solve(PyObject *me, PyObject *arg)
goto end;
Py_INCREF(q);
if (!PySequence_Check(q)) TYERR("want a sequence of residues");
goto end;
Py_INCREF(q);
if (!PySequence_Check(q)) TYERR("want a sequence of residues");
- if (PySequence_Size(q) != n) VALERR("residue count mismatch");
+ i = PySequence_Size(q); if (i < 0) goto end;
+ if (i != n) VALERR("residue count mismatch");
v = xmalloc(n * sizeof(*v));
for (i = 0; i < n; i++) {
if ((x = PySequence_GetItem(q, i)) == 0) goto end;
v = xmalloc(n * sizeof(*v));
for (i = 0; i < n; i++) {
if ((x = PySequence_GetItem(q, i)) == 0) goto end;
@@
-1732,8
+1733,7
@@
static PyObject *mpcrt_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
goto end;
Py_INCREF(q);
if (!PySequence_Check(q)) TYERR("want a sequence of moduli");
goto end;
Py_INCREF(q);
if (!PySequence_Check(q)) TYERR("want a sequence of moduli");
- n = PySequence_Size(q);
- if (PyErr_Occurred()) goto end;
+ n = PySequence_Size(q); if (n < 0) goto end;
if (!n) VALERR("want at least one modulus");
v = xmalloc(n * sizeof(*v));
for (i = 0; i < n; i++) {
if (!n) VALERR("want at least one modulus");
v = xmalloc(n * sizeof(*v));
for (i = 0; i < n; i++) {