Fix segfault in table_lookup() on an empty table
This commit is contained in:
parent
86194ae081
commit
27950453e3
3
table.c
3
table.c
|
@ -125,6 +125,9 @@ int table_insert(struct table *t, void *entry)
|
||||||
|
|
||||||
void *table_lookup(struct table *t, int idx)
|
void *table_lookup(struct table *t, int idx)
|
||||||
{
|
{
|
||||||
|
if (t->size < 1)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (t->dirty) {
|
if (t->dirty) {
|
||||||
t->lookup = realloc(t->lookup, t->size*sizeof(void *));
|
t->lookup = realloc(t->lookup, t->size*sizeof(void *));
|
||||||
// TODO: check allocation
|
// TODO: check allocation
|
||||||
|
|
Loading…
Reference in New Issue