From: Victor Julien Date: Thu, 31 Mar 2016 08:04:44 +0000 (+0200) Subject: hyperscan: fix minor coverity warning 1358024 X-Git-Tag: suricata-3.0.1~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2ccf028eac9ed88fe16a6f7d473ae97c4062732a;p=thirdparty%2Fsuricata.git hyperscan: fix minor coverity warning 1358024 *** CID 1358024: Null pointer dereferences (REVERSE_INULL) /src/util-mpm-hs.c: 1043 in SCHSPrintInfo() 1037 printf(" SCHSPattern %" PRIuMAX "\n", (uintmax_t)sizeof(SCHSPattern)); 1038 printf("Unique Patterns: %" PRIu32 "\n", mpm_ctx->pattern_cnt); 1039 printf("Smallest: %" PRIu32 "\n", mpm_ctx->minlen); 1040 printf("Largest: %" PRIu32 "\n", mpm_ctx->maxlen); 1041 printf("\n"); 1042 >>> CID 1358024: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "ctx" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 1043 if (ctx) { 1044 char *db_info = NULL; 1045 if (hs_database_info(pd->hs_db, &db_info) == HS_SUCCESS) { 1046 printf("HS Database Info: %s\n", db_info); 1047 SCFree(db_info); 1048 } --- diff --git a/src/util-mpm-hs.c b/src/util-mpm-hs.c index 2f6237e9e7..be4a93d0cd 100644 --- a/src/util-mpm-hs.c +++ b/src/util-mpm-hs.c @@ -1026,7 +1026,6 @@ void SCHSPrintSearchStats(MpmThreadCtx *mpm_thread_ctx) void SCHSPrintInfo(MpmCtx *mpm_ctx) { SCHSCtx *ctx = (SCHSCtx *)mpm_ctx->ctx; - PatternDatabase *pd = ctx->pattern_db; printf("MPM HS Information:\n"); printf("Memory allocs: %" PRIu32 "\n", mpm_ctx->memory_cnt); @@ -1041,6 +1040,7 @@ void SCHSPrintInfo(MpmCtx *mpm_ctx) printf("\n"); if (ctx) { + PatternDatabase *pd = ctx->pattern_db; char *db_info = NULL; if (hs_database_info(pd->hs_db, &db_info) == HS_SUCCESS) { printf("HS Database Info: %s\n", db_info);