]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
hyperscan: fix minor coverity warning 1358024
authorVictor Julien <victor@inliniac.net>
Thu, 31 Mar 2016 08:04:44 +0000 (10:04 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 31 Mar 2016 08:04:44 +0000 (10:04 +0200)
*** 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             }

src/util-mpm-hs.c

index 2f6237e9e7aecd1f87230a6faed0b10432edb83c..be4a93d0cd877bf0b127b3377ea1842cd7f22075 100644 (file)
@@ -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);