Fix segfault in table_lookup() on an empty table

This commit is contained in:
Maurizio Porrato 2020-09-05 08:45:35 +01:00
parent 86194ae081
commit 27950453e3
1 changed files with 3 additions and 0 deletions

View File

@ -125,6 +125,9 @@ int table_insert(struct table *t, void *entry)
void *table_lookup(struct table *t, int idx)
{
if (t->size < 1)
return NULL;
if (t->dirty) {
t->lookup = realloc(t->lookup, t->size*sizeof(void *));
// TODO: check allocation