]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
napatech: fix minor memleak in error path
authorVictor Julien <victor@inliniac.net>
Thu, 19 Oct 2017 07:03:13 +0000 (09:03 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 19 Oct 2017 08:40:06 +0000 (10:40 +0200)
src/runmode-napatech.c

index d03fed623c811968381cca885185dc036eb1171e..60fe699f673f16c8cd6a6fabeccdd2aff4a7cbe2 100644 (file)
@@ -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);