From fdb5f696c437f2f07d9bf67700c793f4aec37342 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Tue, 22 Jun 2021 08:16:40 +0200 Subject: [PATCH] modbus: fix memory leak in signature parsing Bug: #4538. --- src/detect-modbus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/detect-modbus.c b/src/detect-modbus.c index 53d93b45fe..ef689f1758 100644 --- a/src/detect-modbus.c +++ b/src/detect-modbus.c @@ -412,9 +412,13 @@ static DetectModbus *DetectModbusUnitIdParse(const char *str) if ((modbus = DetectModbusFunctionParse(str_ptr)) == NULL) { if ((modbus = DetectModbusAccessParse(str_ptr)) == NULL) { SCLogError(SC_ERR_PCRE_MATCH, "invalid modbus option"); + if (str_ptr != NULL) + pcre_free_substring(str_ptr); goto error; } } + if (str_ptr != NULL) + pcre_free_substring(str_ptr); } else { /* We have only unit id Modbus option */ modbus = (DetectModbus *) SCCalloc(1, sizeof(DetectModbus)); -- 2.47.2