[Python-checkins] CVS: python/dist/src/Python modsupport.c,2.56,2.57
Fred L. Drake
fdrake@users.sourceforge.net
Fri, 03 Aug 2001 20:11:27 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv18370
Modified Files:
modsupport.c
Log Message:
Plug a memory leak in Py_InitModule4(): when PyDict_SetItemString() failed,
the object being inserted was not being DECREFed.
This closes SF bug #444486.
Index: modsupport.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v
retrieving revision 2.56
retrieving revision 2.57
diff -C2 -d -r2.56 -r2.57
*** modsupport.c 2001/07/31 13:24:44 2.56
--- modsupport.c 2001/08/04 03:11:25 2.57
***************
*** 61,72 ****
if (v == NULL)
return NULL;
! if (PyDict_SetItemString(d, ml->ml_name, v) != 0)
return NULL;
Py_DECREF(v);
}
if (doc != NULL) {
v = PyString_FromString(doc);
! if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0)
return NULL;
Py_DECREF(v);
}
--- 61,76 ----
if (v == NULL)
return NULL;
! if (PyDict_SetItemString(d, ml->ml_name, v) != 0) {
! Py_DECREF(v);
return NULL;
+ }
Py_DECREF(v);
}
if (doc != NULL) {
v = PyString_FromString(doc);
! if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) {
! Py_DECREF(v);
return NULL;
+ }
Py_DECREF(v);
}