From: Victor Julien Date: Thu, 21 Dec 2017 11:00:28 +0000 (+0100) Subject: detect/tos: fix memleak in error path X-Git-Tag: suricata-4.1.0-beta1~380 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c36ea64c28d6cb64729cc1d942b84d35c189bdc;p=thirdparty%2Fsuricata.git detect/tos: fix memleak in error path --- diff --git a/src/detect-tos.c b/src/detect-tos.c index 1675374355..2d7c4e0a20 100644 --- a/src/detect-tos.c +++ b/src/detect-tos.c @@ -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; } /**