From: Michael Andres Date: Tue, 5 Feb 2008 20:33:39 +0000 (+0000) Subject: fix segv when str2id(pool,NULL) X-Git-Tag: BASE-SuSE-Code-12_1-Branch~308^2~670 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d1563de904b41b6ba4ec625db60509a0e276b2e;p=thirdparty%2Flibsolv.git fix segv when str2id(pool,NULL) --- diff --git a/src/strpool.c b/src/strpool.c index 4d091396..79e450b4 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); }