mirror of
https://salsa.debian.org/ha-team/libqb
synced 2026-08-22 14:01:09 +00:00
COV 8: don't leak mem when returning an error.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
parent
9724860b9a
commit
24107d56ef
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user