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); }