[Zodb-checkins] CVS: Zope/lib/python/BTrees - BucketTemplate.c:1.42
Tim Peters
tim.one@comcast.net
Mon, 17 Jun 2002 15:03:55 -0400
Update of /cvs-repository/Zope/lib/python/BTrees
In directory cvs.zope.org:/tmp/cvs-serv31702
Modified Files:
BucketTemplate.c
Log Message:
Bucket_grow(): This could leak memory in error cases; repaired.
=== Zope/lib/python/BTrees/BucketTemplate.c 1.41 => 1.42 ===
UNLESS (noval)
{
- UNLESS (values = PyRealloc(self->values,
- sizeof(VALUE_TYPE) * newsize))
- return -1;
+ values = PyRealloc(self->values, sizeof(VALUE_TYPE) * newsize);
+ if (values == NULL)
+ {
+ free(keys);
+ return -1;
+ }
self->values = values;
}
self->keys = keys;
@@ -155,8 +158,13 @@
return -1;
UNLESS (noval)
{
- UNLESS (self->values = PyMalloc(sizeof(VALUE_TYPE) * newsize))
- return -1;
+ self->values = PyMalloc(sizeof(VALUE_TYPE) * newsize);
+ if (self->values == NULL)
+ {
+ free(self->keys);
+ self->keys = NULL;
+ return -1;
+ }
}
}
self->size = newsize;