detect/tos: fix memleak in error path

pull/3117/head
Victor Julien 9 years ago
parent 2a4b5adce8
commit 0c36ea64c2

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

Loading…
Cancel
Save