]> 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)
committerShivani Bhardwaj <shivanib134@gmail.com>
Thu, 3 Dec 2020 22:39:55 +0000 (04:09 +0530)
scripts/dnp3-gen/dnp3-gen.py

index c5f2ce5668789dbc7c289d74547638a94a1e0839..3f1b124dc68f47c1819bf7905b75149fe5dd34cf 100755 (executable)
@@ -574,6 +574,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);
     }