]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
hyperscan: fix minor coverity warning 1358023 1970/head
authorVictor Julien <victor@inliniac.net>
Thu, 31 Mar 2016 08:07:01 +0000 (10:07 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 31 Mar 2016 08:07:01 +0000 (10:07 +0200)
*** CID 1358023:  Null pointer dereferences  (REVERSE_INULL)
/src/util-mpm-hs.c: 860 in SCHSDestroyThreadCtx()
854         if (thr_ctx->scratch != NULL) {
855             hs_free_scratch(thr_ctx->scratch);
856             mpm_thread_ctx->memory_cnt--;
857             mpm_thread_ctx->memory_size -= thr_ctx->scratch_size;
858         }
859
>>>     CID 1358023:  Null pointer dereferences  (REVERSE_INULL)
>>>     Null-checking "mpm_thread_ctx->ctx" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
860         if (mpm_thread_ctx->ctx != NULL) {
861             SCFree(mpm_thread_ctx->ctx);
862             mpm_thread_ctx->ctx = NULL;
863             mpm_thread_ctx->memory_cnt--;
864             mpm_thread_ctx->memory_size -= sizeof(SCHSThreadCtx);
865         }

src/util-mpm-hs.c

index be4a93d0cd877bf0b127b3377ea1842cd7f22075..c9c92db664b0f021ea44eb9af9469cb8de54b400 100644 (file)
@@ -849,15 +849,15 @@ void SCHSDestroyThreadCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx)
 {
     SCHSPrintSearchStats(mpm_thread_ctx);
 
-    SCHSThreadCtx *thr_ctx = (SCHSThreadCtx *)mpm_thread_ctx->ctx;
+    if (mpm_thread_ctx->ctx != NULL) {
+        SCHSThreadCtx *thr_ctx = (SCHSThreadCtx *)mpm_thread_ctx->ctx;
 
-    if (thr_ctx->scratch != NULL) {
-        hs_free_scratch(thr_ctx->scratch);
-        mpm_thread_ctx->memory_cnt--;
-        mpm_thread_ctx->memory_size -= thr_ctx->scratch_size;
-    }
+        if (thr_ctx->scratch != NULL) {
+            hs_free_scratch(thr_ctx->scratch);
+            mpm_thread_ctx->memory_cnt--;
+            mpm_thread_ctx->memory_size -= thr_ctx->scratch_size;
+        }
 
-    if (mpm_thread_ctx->ctx != NULL) {
         SCFree(mpm_thread_ctx->ctx);
         mpm_thread_ctx->ctx = NULL;
         mpm_thread_ctx->memory_cnt--;