From: Victor Julien Date: Thu, 28 Jul 2022 09:17:04 +0000 (+0200) Subject: detect/file: minor cleanups X-Git-Tag: suricata-7.0.0-beta1~361 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad3e68f3781f62cc3f529f055881cfc1cb5a44bf;p=thirdparty%2Fsuricata.git detect/file: minor cleanups --- diff --git a/src/detect-fileext.c b/src/detect-fileext.c index 8dd08c62b5..f87a230e7e 100644 --- a/src/detect-fileext.c +++ b/src/detect-fileext.c @@ -206,16 +206,13 @@ error: */ static int DetectFileextSetup (DetectEngineCtx *de_ctx, Signature *s, const char *str) { - DetectFileextData *fileext= NULL; - SigMatch *sm = NULL; - - fileext = DetectFileextParse(de_ctx, str, s->init_data->negated); + DetectFileextData *fileext = DetectFileextParse(de_ctx, str, s->init_data->negated); if (fileext == NULL) - goto error; + return -1; /* Okay so far so good, lets get this into a SigMatch * and put it in the Signature. */ - sm = SigMatchAlloc(); + SigMatch *sm = SigMatchAlloc(); if (sm == NULL) goto error; @@ -228,12 +225,10 @@ static int DetectFileextSetup (DetectEngineCtx *de_ctx, Signature *s, const char return 0; error: - if (fileext != NULL) - DetectFileextFree(de_ctx, fileext); + DetectFileextFree(de_ctx, fileext); if (sm != NULL) SCFree(sm); return -1; - } /** diff --git a/src/detect-filename.c b/src/detect-filename.c index 53479b437e..7aa39ccdb5 100644 --- a/src/detect-filename.c +++ b/src/detect-filename.c @@ -230,14 +230,9 @@ static int DetectFilenameMatch (DetectEngineThreadCtx *det_ctx, */ static DetectFilenameData *DetectFilenameParse (DetectEngineCtx *de_ctx, const char *str, bool negate) { - DetectFilenameData *filename = NULL; - - /* We have a correct filename option */ - filename = SCMalloc(sizeof(DetectFilenameData)); + DetectFilenameData *filename = SCCalloc(1, sizeof(DetectFilenameData)); if (unlikely(filename == NULL)) - goto error; - - memset(filename, 0x00, sizeof(DetectFilenameData)); + return NULL; if (DetectContentDataParse ("filename", str, &filename->name, &filename->len) == -1) { goto error; @@ -272,8 +267,7 @@ static DetectFilenameData *DetectFilenameParse (DetectEngineCtx *de_ctx, const c return filename; error: - if (filename != NULL) - DetectFilenameFree(de_ctx, filename); + DetectFilenameFree(de_ctx, filename); return NULL; }