[Zope-Checkins] CVS: StandaloneZODB/ZODB - cPickleCache.c:1.36

Barry Warsaw barry@wooz.org
Thu, 8 Nov 2001 12:13:02 -0500


Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv7764/ZODB

Modified Files:
	cPickleCache.c 
Log Message:
initcPickleCache(): Some cleanup of the initializer.  First be sure to
decref the revision string, added to the module dict with the keys
"__version__".  This fixes a small leaks detected by Insure.

Also, at the end of the function, we do a PyErr_Occurred() check and
throw a fatal error if true.  This makes this module's init function
more in line with other init functions in this package.


=== StandaloneZODB/ZODB/cPickleCache.c 1.35 => 1.36 ===
 initcPickleCache(void)
 {
-  PyObject *m, *d;
+  PyObject *m, *d, *s;
   char *rev="$Revision$";
 
   Cctype.ob_type=&PyType_Type;
@@ -742,6 +742,11 @@
   py__p_jar=PyString_FromString("_p_jar");
   py__p_changed=PyString_FromString("_p_changed");
 
-  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);
+
+  /* Check for errors */
+  if (PyErr_Occurred())
+    Py_FatalError("can't initialize module cPickleCache");
 }