[Zodb-checkins] CVS: Zope3/src/zodb/storage - _helper.c:1.4

Jeremy Hylton jeremy@zope.com
Wed, 2 Apr 2003 15:29:57 -0500


Update of /cvs-repository/Zope3/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv5924

Modified Files:
	_helper.c 
Log Message:
Fix leaks of two longs.


=== Zope3/src/zodb/storage/_helper.c 1.3 => 1.4 ===
--- Zope3/src/zodb/storage/_helper.c:1.3	Wed Jan 22 14:18:45 2003
+++ Zope3/src/zodb/storage/_helper.c	Wed Apr  2 15:29:57 2003
@@ -26,7 +26,7 @@
 static PyObject*
 helper_incr(PyObject* self, PyObject* args)
 {
-    PyObject *pylong, *incr, *sum;
+    PyObject *pylong = NULL, *incr, *sum = NULL, *result = NULL;
     char *s, x[8];
     int len, res;
 
@@ -48,15 +48,19 @@
 
     sum = PyNumber_Add(pylong, incr);
     if (!sum)
-        return NULL;
+	goto err;
 
     res = _PyLong_AsByteArray((PyLongObject*)sum, x, 8,
                               0 /* big endian */,
                               0 /* unsigned */);
     if (res < 0)
-        return NULL;
+	goto err;
 
-    return PyString_FromStringAndSize(x, 8);
+    result = PyString_FromStringAndSize(x, 8);
+ err:
+    Py_XDECREF(pylong);
+    Py_XDECREF(sum);
+    return result;
 }