*/
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;
return 0;
error:
- if (fileext != NULL)
- DetectFileextFree(de_ctx, fileext);
+ DetectFileextFree(de_ctx, fileext);
if (sm != NULL)
SCFree(sm);
return -1;
-
}
/**
*/
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;
return filename;
error:
- if (filename != NULL)
- DetectFilenameFree(de_ctx, filename);
+ DetectFilenameFree(de_ctx, filename);
return NULL;
}