]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/tos: fix memleak in error path
authorVictor Julien <victor@inliniac.net>
Thu, 21 Dec 2017 11:00:28 +0000 (12:00 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 30 Jan 2018 09:32:17 +0000 (10:32 +0100)
src/detect-tos.c

index 1675374355c97be1bc6f38f81523ed722ea97498..2d7c4e0a20545a540343207574be6fe29fb05212 100644 (file)
@@ -177,13 +177,15 @@ int DetectTosSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg)
 
     tosd = DetectTosParse(arg, s->init_data->negated);
     if (tosd == NULL)
-        goto error;
+        return -1;
 
     /* Okay so far so good, lets get this into a SigMatch
      * and put it in the Signature. */
     sm = SigMatchAlloc();
-    if (sm == NULL)
-        goto error;
+    if (sm == NULL) {
+        DetectTosFree(tosd);
+        return -1;
+    }
 
     sm->type = DETECT_TOS;
     sm->ctx = (SigMatchCtx *)tosd;
@@ -192,9 +194,6 @@ int DetectTosSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg)
     s->flags |= SIG_FLAG_REQUIRE_PACKET;
 
     return 0;
-
-error:
-    return -1;
 }
 
 /**