From: Victor Julien Date: Thu, 19 Oct 2017 07:03:13 +0000 (+0200) Subject: napatech: fix minor memleak in error path X-Git-Tag: suricata-4.0.2~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf0a28bc6af96f5cba1da347eedf1f9430edaa73;p=thirdparty%2Fsuricata.git napatech: fix minor memleak in error path --- diff --git a/src/runmode-napatech.c b/src/runmode-napatech.c index d03fed623c..60fe699f67 100644 --- a/src/runmode-napatech.c +++ b/src/runmode-napatech.c @@ -123,15 +123,16 @@ static void *NapatechConfigParser(const char *device) { /* Expect device to be of the form nt%d where %d is the stream id to use */ int dev_len = strlen(device); + if (dev_len < 3 || dev_len > 5) { + SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG, "Could not parse config for device: %s - invalid length", device); + return NULL; + } + struct NapatechStreamDevConf *conf = SCCalloc(1, sizeof (struct NapatechStreamDevConf)); if (unlikely(conf == NULL)) { SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for NAPATECH device name."); return NULL; } - if (dev_len < 3 || dev_len > 5) { - SCLogError(SC_ERR_NAPATECH_PARSE_CONFIG, "Could not parse config for device: %s - invalid length", device); - return NULL; - } /* device+5 is a pointer to the beginning of the stream id after the constant nt portion */ conf->stream_id = atoi(device + 2);