From: Mark Wooding Date: Sun, 10 Nov 2019 22:41:19 +0000 (+0000) Subject: mp.c: Arrange to free `xx' on exit. X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/commitdiff_plain/4e02c19cca797d71f0479e9dea0bf07b61388dd5 mp.c: Arrange to free `xx' on exit. --- diff --git a/mp.c b/mp.c index 77f7c3c..fff4aec 100644 --- 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; - mp *xx; + mp *xx = MP_NEW; mpcrt_pyobj *c = 0; if (PyTuple_Size(arg) > 1) @@ -1738,11 +1738,12 @@ static PyObject *mpcrt_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) if ((x = PySequence_GetItem(q, i)) == 0) goto end; xx = getmp(x); Py_DECREF(x); if (!xx) goto end; 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; + 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); + mp_drop(xx); return ((PyObject *)c); end: @@ -1753,6 +1754,7 @@ end: xfree(v); } Py_XDECREF(q); + mp_drop(xx); return (0); }