From 5749024e3f21d503e074b59208e0753629552d1c Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Thu, 19 Nov 2020 14:29:48 +0100 Subject: [PATCH] dnp3: fix memory leak with object containing bytearrays --- scripts/dnp3-gen/dnp3-gen.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/dnp3-gen/dnp3-gen.py b/scripts/dnp3-gen/dnp3-gen.py index 5b68203fa3..b2226c3217 100755 --- a/scripts/dnp3-gen/dnp3-gen.py +++ b/scripts/dnp3-gen/dnp3-gen.py @@ -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); }