[Python-checkins] python/dist/src/Modules mpzmodule.c,2.45,2.46
nnorwitz@users.sourceforge.net
nnorwitz@users.sourceforge.net
Tue, 13 Aug 2002 19:03:52 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv13175/Modules
Modified Files:
mpzmodule.c
Log Message:
Fix memory leaks reported by valgrind
Index: mpzmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/mpzmodule.c,v
retrieving revision 2.45
retrieving revision 2.46
diff -C2 -d -r2.45 -r2.46
*** mpzmodule.c 2 Aug 2002 02:27:13 -0000 2.45
--- mpzmodule.c 14 Aug 2002 02:03:50 -0000 2.46
***************
*** 962,966 ****
PyObject *base, *exp, *mod;
mpzobject *mpzbase = NULL, *mpzexp = NULL, *mpzmod = NULL;
! mpzobject *z;
int tstres;
--- 962,966 ----
PyObject *base, *exp, *mod;
mpzobject *mpzbase = NULL, *mpzexp = NULL, *mpzmod = NULL;
! mpzobject *z = NULL;
int tstres;
***************
*** 976,983 ****
--- 976,988 ----
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;
***************
*** 988,991 ****
--- 993,997 ----
Py_DECREF(mpzexp);
Py_DECREF(mpzmod);
+ Py_DECREF(z);
PyErr_SetString(PyExc_ValueError, "modulus cannot be 0");
return NULL;