Skip to content

Commit f00e027

Browse files
committed
Merge branch 'AigarsG-dictionary_new_calloc_checks'
2 parents b726472 + 6fc4ec0 commit f00e027

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/dictionary.c

+7
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ dictionary * dictionary_new(size_t size)
154154
d->val = (char**) calloc(size, sizeof *d->val);
155155
d->key = (char**) calloc(size, sizeof *d->key);
156156
d->hash = (unsigned*) calloc(size, sizeof *d->hash);
157+
if (!d->size || !d->val || !d->hash) {
158+
free((void *) d->size);
159+
free((void *) d->val);
160+
free((void *) d->hash);
161+
free(d);
162+
d = NULL;
163+
}
157164
}
158165
return d ;
159166
}

0 commit comments

Comments
 (0)