From ef3d2573f36533523659ce0ea434c6316a6a9017 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 c5f2ce5668..3f1b124dc6 100755 --- a/scripts/dnp3-gen/dnp3-gen.py +++ b/scripts/dnp3-gen/dnp3-gen.py @@ -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); } -- 2.47.2