diff --git a/src/dictionary.c b/src/dictionary.c index 71ee2d6..85dfdc0 100644 --- a/src/dictionary.c +++ b/src/dictionary.c @@ -154,6 +154,13 @@ dictionary * dictionary_new(size_t size) d->val = (char**) calloc(size, sizeof *d->val); d->key = (char**) calloc(size, sizeof *d->key); d->hash = (unsigned*) calloc(size, sizeof *d->hash); + if (!d->size || !d->val || !d->hash) { + free((void *) d->size); + free((void *) d->val); + free((void *) d->hash); + free(d); + d = NULL; + } } return d ; }