]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
modbus: fix memory leak in signature parsing 6223/head
authorPhilippe Antoine <contact@catenacyber.fr>
Tue, 22 Jun 2021 06:16:40 +0000 (08:16 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 22 Jun 2021 18:55:43 +0000 (20:55 +0200)
Bug: #4538.

src/detect-modbus.c

index 53d93b45fec961d05e9e958dae7031e05ecc56b3..ef689f175864dda662fb00d61737d0efb4a4ac54 100644 (file)
@@ -412,9 +412,13 @@ static DetectModbus *DetectModbusUnitIdParse(const char *str)
         if ((modbus = DetectModbusFunctionParse(str_ptr)) == NULL) {
             if ((modbus = DetectModbusAccessParse(str_ptr)) == NULL) {
                 SCLogError(SC_ERR_PCRE_MATCH, "invalid modbus option");
+                if (str_ptr != NULL)
+                    pcre_free_substring(str_ptr);
                 goto error;
             }
         }
+        if (str_ptr != NULL)
+            pcre_free_substring(str_ptr);
     } else {
         /* We have only unit id Modbus option */
         modbus = (DetectModbus *) SCCalloc(1, sizeof(DetectModbus));