]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/frames: fix coverity warning 6860/head
authorVictor Julien <vjulien@oisf.net>
Tue, 25 Jan 2022 07:07:33 +0000 (08:07 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 25 Jan 2022 07:16:00 +0000 (08:16 +0100)
Harmless warning, but it was correct in that the code made no sense:
1497420 Dereference before null check

src/detect-engine.c

index 0db3967b9e13cd4daec2a45900e8ba75b5ad5af5..32bb48157a89828a6e28cb66734b67bcc48c7d46 100644 (file)
@@ -463,7 +463,7 @@ static void DetectFrameInspectEngineCopy(DetectEngineCtx *de_ctx, int sm_list, i
 {
     /* take the list from the detect engine as the buffers can be registered
      * dynamically. */
-    const DetectEngineFrameInspectionEngine *t = de_ctx->frame_inspect_engines;
+    DetectEngineFrameInspectionEngine *t = de_ctx->frame_inspect_engines;
     while (t) {
         if (t->sm_list == sm_list) {
             DetectEngineFrameInspectionEngine *new_engine =
@@ -479,16 +479,14 @@ static void DetectFrameInspectEngineCopy(DetectEngineCtx *de_ctx, int sm_list, i
             new_engine->v1 = t->v1;
             new_engine->v1.transforms = transforms; /* assign transforms */
 
-            if (de_ctx->frame_inspect_engines == NULL) {
-                de_ctx->frame_inspect_engines = new_engine;
-            } else {
-                DetectEngineFrameInspectionEngine *list = de_ctx->frame_inspect_engines;
-                while (list->next != NULL) {
-                    list = list->next;
-                }
-
-                list->next = new_engine;
+            /* append to the list */
+            DetectEngineFrameInspectionEngine *list = t;
+            while (list->next != NULL) {
+                list = list->next;
             }
+
+            list->next = new_engine;
+            break;
         }
         t = t->next;
     }