From: Victor Julien Date: Mon, 18 Feb 2019 14:17:36 +0000 (+0100) Subject: decoder: improve stats hash error handling X-Git-Tag: suricata-5.0.0-beta1~193 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43698a975acda124fbecc8b598595c23971571a9;p=thirdparty%2Fsuricata.git decoder: improve stats hash error handling --- diff --git a/src/decode.c b/src/decode.c index 3a109b378f..dfcd8dacf9 100644 --- a/src/decode.c +++ b/src/decode.c @@ -496,7 +496,10 @@ void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv) g_counter_table = HashTableInit(256, StringHashFunc, StringHashCompareFunc, StringHashFreeFunc); - BUG_ON(g_counter_table == NULL); + if (g_counter_table == NULL) { + FatalError(SC_ERR_INITIALIZATION, "decoder counter hash " + "table init failed"); + } } char name[256]; @@ -508,8 +511,13 @@ void DecodeRegisterPerfCounters(DecodeThreadVars *dtv, ThreadVars *tv) const char *found = HashTableLookup(g_counter_table, name, 0); if (!found) { char *add = SCStrdup(name); - BUG_ON(!add); - HashTableAdd(g_counter_table, add, 0); + if (add == NULL) + FatalError(SC_ERR_INITIALIZATION, "decoder counter hash " + "table name init failed"); + int r = HashTableAdd(g_counter_table, add, 0); + if (r != 0) + FatalError(SC_ERR_INITIALIZATION, "decoder counter hash " + "table name add failed"); found = add; } dtv->counter_engine_events[i] = StatsRegisterCounter(