From 2d1563de904b41b6ba4ec625db60509a0e276b2e Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Tue, 5 Feb 2008 20:33:39 +0000 Subject: [PATCH] fix segv when str2id(pool,NULL) --- src/strpool.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/strpool.c b/src/strpool.c index 4d09139..79e450b 100644 --- a/src/strpool.c +++ b/src/strpool.c @@ -42,7 +42,7 @@ void stringpool_init_empty(Stringpool *ss) { const char *emptystrs[] = { - "", + "", "", 0, }; @@ -81,8 +81,8 @@ stringpool_strn2id (Stringpool *ss, const char *str, unsigned len, int create) hashtbl = ss->stringhashtbl; // expand hashtable if needed - // - // + // + // if (ss->nstrings * 2 > hashmask) { sat_free(hashtbl); @@ -142,6 +142,10 @@ stringpool_strn2id (Stringpool *ss, const char *str, unsigned len, int create) Id stringpool_str2id (Stringpool *ss, const char *str, int create) { + if ( !str ) + return STRID_NULL; + if ( !*str ) + return STRID_EMPTY; unsigned len = strlen (str); return stringpool_strn2id (ss, str, len, create); } -- 2.7.4