~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mp.c: Arrange to free `xx' on exit.
[catacomb-python]
/
mp.c
diff --git
a/mp.c
b/mp.c
index
a234c6d
..
fff4aec
100644
(file)
--- a/
mp.c
+++ b/
mp.c
@@
-1721,7
+1721,7
@@
static PyObject *mpcrt_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
int n, i = 0;
char *kwlist[] = { "mv", 0 };
PyObject *q = 0, *x;
int n, i = 0;
char *kwlist[] = { "mv", 0 };
PyObject *q = 0, *x;
- mp *xx;
+ mp *xx
= MP_NEW
;
mpcrt_pyobj *c = 0;
if (PyTuple_Size(arg) > 1)
mpcrt_pyobj *c = 0;
if (PyTuple_Size(arg) > 1)
@@
-1737,11
+1737,13
@@
static PyObject *mpcrt_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
for (i = 0; i < n; i++) {
if ((x = PySequence_GetItem(q, i)) == 0) goto end;
xx = getmp(x); Py_DECREF(x); if (!xx) goto end;
for (i = 0; i < n; i++) {
if ((x = PySequence_GetItem(q, i)) == 0) goto end;
xx = getmp(x); Py_DECREF(x); if (!xx) goto end;
- v[i].m = xx; v[i].n = 0; v[i].ni = 0; v[i].nni = 0;
+ if (MP_CMP(xx, <=, MP_ZERO)) VALERR("moduli must be positive");
+ v[i].m = xx; v[i].n = 0; v[i].ni = 0; v[i].nni = 0; xx = MP_NEW;
}
c = (mpcrt_pyobj *)ty->tp_alloc(ty, 0);
mpcrt_create(&c->c, v, n, 0);
Py_DECREF(q);
}
c = (mpcrt_pyobj *)ty->tp_alloc(ty, 0);
mpcrt_create(&c->c, v, n, 0);
Py_DECREF(q);
+ mp_drop(xx);
return ((PyObject *)c);
end:
return ((PyObject *)c);
end:
@@
-1752,6
+1754,7
@@
end:
xfree(v);
}
Py_XDECREF(q);
xfree(v);
}
Py_XDECREF(q);
+ mp_drop(xx);
return (0);
}
return (0);
}