From: Victor Julien Date: Mon, 9 Dec 2013 20:15:22 +0000 (+0100) Subject: Fix small memleak in runmode setup X-Git-Tag: suricata-2.0beta2~45 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=435f99409f6eedfc8093d598ff4a0ebbcecacbb2;p=thirdparty%2Fsuricata.git Fix small memleak in runmode setup [src/runmodes.c:338]: (error) Memory leak: custom_mode --- diff --git a/src/runmodes.c b/src/runmodes.c index c714500864..5f20ed974a 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -245,6 +245,8 @@ void RunModeListRunmodes(void) void RunModeDispatch(int runmode, const char *custom_mode, DetectEngineCtx *de_ctx) { + char *local_custom_mode = NULL; + if (custom_mode == NULL) { char *val = NULL; if (ConfGet("runmode", &val) != 1) { @@ -300,11 +302,12 @@ void RunModeDispatch(int runmode, const char *custom_mode, DetectEngineCtx *de_c if (!strcmp("worker", custom_mode)) { SCLogWarning(SC_ERR_RUNMODE, "'worker' mode have been renamed " "to 'workers', please modify your setup."); - custom_mode = SCStrdup("workers"); - if (unlikely(custom_mode == NULL)) { + local_custom_mode = SCStrdup("workers"); + if (unlikely(local_custom_mode == NULL)) { SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup custom mode"); exit(EXIT_FAILURE); } + custom_mode = local_custom_mode; } } @@ -335,6 +338,8 @@ void RunModeDispatch(int runmode, const char *custom_mode, DetectEngineCtx *de_c mode->RunModeFunc(de_ctx); + if (local_custom_mode != NULL) + SCFree(local_custom_mode); return; }