[Zodb-checkins] CVS: Zope/lib/python/BTrees - BTreeTemplate.c:1.51

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


Update of /cvs-repository/Zope/lib/python/BTrees
In directory cvs.zope.org:/tmp/cvs-serv4094

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.


=== Zope/lib/python/BTrees/BTreeTemplate.c 1.50 => 1.51 ===
     {
       bucket = self->firstbucket;
-      Py_INCREF(bucket);
       PER_ALLOW_DEACTIVATION(self);
       PER_ACCESSED(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)
         {
@@ -1158,9 +1154,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;