Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
lib/array.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/lib/array.c b/lib/array.c
index aa7bef9..937e7f1 100644
--- a/lib/array.c
+++ b/lib/array.c
@@ -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;
--
1.7.5.1