COV 8: don't leak mem when returning an error.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2011-05-20 14:22:37 +10:00
parent 9724860b9a
commit 24107d56ef

View File

@ -38,7 +38,7 @@ struct qb_array {
qb_array_t* qb_array_create(size_t max_elements, size_t element_size)
{
int32_t i;
struct qb_array *a = calloc(1, sizeof(struct qb_array));
struct qb_array *a = NULL;
if (max_elements > (MAX_BIN_ELEMENTS*MAX_BINS)) {
errno = -EINVAL;
@ -48,6 +48,10 @@ qb_array_t* qb_array_create(size_t max_elements, size_t element_size)
errno = -EINVAL;
return NULL;
}
a = calloc(1, sizeof(struct qb_array));
if (a == NULL) {
return NULL;
}
a->element_size = element_size;
a->max_elements = max_elements;
a->num_bins = (max_elements / MAX_BIN_ELEMENTS) + 1;