[Zope-Checkins] CVS: Zope3/lib/python/Persistence/BTrees - BTreeTemplate.c:1.14

Tim Peters tim.one@comcast.net
Thu, 13 Jun 2002 10:07:15 -0400


Update of /cvs-repository/Zope3/lib/python/Persistence/BTrees
In directory cvs.zope.org:/tmp/cvs-serv5024

Modified Files:
	BTreeTemplate.c 
Log Message:
BTree_rangeSearch():  Squash another case of bucket-leak-on-PER_USE-failure,
plus cleanup of a previous such fix.


=== Zope3/lib/python/Persistence/BTrees/BTreeTemplate.c 1.13 => 1.14 ===
     {
       bucket = self->firstbucket;
-      Py_INCREF(bucket);
       PyPersist_DECREF(self);
       PyPersist_SetATime(self);
-      UNLESS (PER_USE(bucket))
-        {
-          Py_DECREF(bucket);
-          return NULL;
-        }
+      UNLESS (PER_USE(bucket)) return NULL;
+      Py_INCREF(bucket);
       offset = 0;
       if (offset >= bucket->len)
         {
@@ -1216,9 +1212,11 @@
   else
     {
       highbucket = BTree_lastBucket(self);
+      assert(highbucket != NULL);  /* we know self isn't empty */
       UNLESS (PER_USE(highbucket))
         {
           Py_DECREF(lowbucket);
+          Py_DECREF(highbucket);
           goto err;
         }
       highoffset = highbucket->len - 1;