[Zodb-checkins] CVS: Zope/lib/python/BTrees - BucketTemplate.c:1.41

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


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

Modified Files:
	BucketTemplate.c 
Log Message:
Bucket_rangeSearch():  If the min key passed in was larger than the max key
passed in, it was quite possible for this to return *low > *high, and the
caller could crash due to trying to create a list with "negative length".
Changed the routine to consider a range empty if min>max on input, and added
test cases that fail before this patch.


=== Zope/lib/python/BTrees/BucketTemplate.c 1.40 => 1.41 ===
         }
     }
-  else *high=self->len - 1;
+  else *high = self->len - 1;
 
-  return 0;
+  /* If f < l to begin with, it's quite possible that low > high now. */
+  if (*low <= *high)
+    return 0;
 
  empty:
-  *low=0;
-  *high=-1;
+  *low = 0;
+  *high = -1;
   return 0;
 }