summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2002-08-14 02:03:50 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2002-08-14 02:03:50 (GMT)
commit72cf6a8c071864581a8a4b8d395b201de8ccfc82 (patch)
tree41caff304fd8292929eda57240e3b771a6216d60 /Modules
parent23b5918f68fa083e4622d99ddf9c4bbd5942d10b (diff)
downloadcpython-72cf6a8c071864581a8a4b8d395b201de8ccfc82.zip
cpython-72cf6a8c071864581a8a4b8d395b201de8ccfc82.tar.gz
cpython-72cf6a8c071864581a8a4b8d395b201de8ccfc82.tar.bz2
Fix memory leaks reported by valgrind
Diffstat (limited to 'Modules')
-rw-r--r--Modules/mpzmodule.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/mpzmodule.c b/Modules/mpzmodule.c
index 5974df1..4641298 100644
--- a/Modules/mpzmodule.c
+++ b/Modules/mpzmodule.c
@@ -961,7 +961,7 @@ MPZ_powm(PyObject *self, PyObject *args)
{
PyObject *base, *exp, *mod;
mpzobject *mpzbase = NULL, *mpzexp = NULL, *mpzmod = NULL;
- mpzobject *z;
+ mpzobject *z = NULL;
int tstres;
@@ -975,10 +975,15 @@ MPZ_powm(PyObject *self, PyObject *args)
Py_XDECREF(mpzbase);
Py_XDECREF(mpzexp);
Py_XDECREF(mpzmod);
+ Py_XDECREF(z);
return NULL;
}
if ((tstres=mpz_cmp_ui(&mpzexp->mpz, (unsigned long int)0)) == 0) {
+ Py_DECREF(mpzbase);
+ Py_DECREF(mpzexp);
+ Py_DECREF(mpzmod);
+ Py_DECREF(z);
Py_INCREF(mpz_value_one);
return (PyObject *)mpz_value_one;
}
@@ -987,6 +992,7 @@ MPZ_powm(PyObject *self, PyObject *args)
Py_DECREF(mpzbase);
Py_DECREF(mpzexp);
Py_DECREF(mpzmod);
+ Py_DECREF(z);
PyErr_SetString(PyExc_ValueError, "modulus cannot be 0");
return NULL;
}