]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dnp3: fix memory leak with object containing bytearrays
authorPhilippe Antoine <contact@catenacyber.fr>
Thu, 19 Nov 2020 13:29:48 +0000 (14:29 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 3 Dec 2020 16:06:49 +0000 (17:06 +0100)
scripts/dnp3-gen/dnp3-gen.py

index 5b68203fa3e24b29765c36b9298f497e5bfa4953..b2226c3217b89c0001a8e48353051f62ce74af28 100755 (executable)
@@ -566,6 +566,13 @@ static int DNP3DecodeObjectG{{object.group}}V{{object.variation}}(const uint8_t
     return 1;
 error:
     if (object != NULL) {
+{% for field in object.fields %}
+{% if field.type == "bytearray" %}
+        if (object->{{field.name}} != NULL) {
+            SCFree(object->{{field.name}});
+        }
+{% endif %}
+{% endfor %}
         SCFree(object);
     }