[Zope-Checkins] CVS: StandaloneZODB/ExtensionClass/src - ExtensionClass.c:1.48

Barry Warsaw barry@wooz.org
Thu, 8 Nov 2001 11:57:54 -0500


Update of /cvs-repository/StandaloneZODB/ExtensionClass/src
In directory cvs.zope.org:/tmp/cvs-serv2647/ExtensionClass/src

Modified Files:
	ExtensionClass.c 
Log Message:
initExtensionClass(): Be sure to decref the revision string and the
cobject (added to the module dict with the keys "__version__" and
"CAPI" respectively).  Fixes small leaks detected by Insure.


=== StandaloneZODB/ExtensionClass/src/ExtensionClass.c 1.47 => 1.48 ===
 initExtensionClass(void)
 {
-  PyObject *m, *d;
+  PyObject *m, *d, *s;
   char *rev="$Revision$";
   PURE_MIXIN_CLASS(Base, "Minimalbase class for Extension Classes", NULL);
 
@@ -3549,8 +3549,9 @@
 		     (PyObject*)NULL,PYTHON_API_VERSION);
 
   d = PyModule_GetDict(m);
-  PyDict_SetItemString(d,"__version__",
-		       PyString_FromStringAndSize(rev+11,strlen(rev+11)-2));
+  s = PyString_FromStringAndSize(rev+11,strlen(rev+11)-2);
+  PyDict_SetItemString(d,"__version__", s);
+  Py_XDECREF(s);
 
   init_py_names();
 
@@ -3567,8 +3568,10 @@
 
   /* Export C attribute lookup API */
   PyExtensionClassCAPI=&TrueExtensionClassCAPI;
-  PyDict_SetItemString(d, "CAPI",
-		       PyCObject_FromVoidPtr(PyExtensionClassCAPI,NULL));
+  
+  s = PyCObject_FromVoidPtr(PyExtensionClassCAPI, NULL);
+  PyDict_SetItemString(d, "CAPI", s);
+  Py_XDECREF(s);
 
   CHECK_FOR_ERRORS("can't initialize module ExtensionClass");
 }