Skip to content

Commit

Permalink
decoder: improve stats hash error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
victorjulien committed Feb 20, 2019
1 parent 517b45e commit 43698a9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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(
Expand Down

0 comments on commit 43698a9

Please sign in to comment.