From 27950453e30ec62013eac448bac1e169408abc86 Mon Sep 17 00:00:00 2001 From: Maurizio Porrato Date: Sat, 5 Sep 2020 08:45:35 +0100 Subject: [PATCH] Fix segfault in table_lookup() on an empty table --- table.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/table.c b/table.c index d357f2e..fc6f866 100644 --- a/table.c +++ b/table.c @@ -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