modbus: fix memory leak in signature parsing

Bug: #4538.
pull/6218/head
Philippe Antoine 5 years ago committed by Victor Julien
parent 6d9a2ec3ee
commit 9ef061dc62

@ -436,9 +436,13 @@ static DetectModbus *DetectModbusUnitIdParse(DetectEngineCtx *de_ctx, const char
if ((modbus = DetectModbusFunctionParse(de_ctx, str_ptr)) == NULL) {
if ((modbus = DetectModbusAccessParse(de_ctx, 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));
@ -1009,4 +1013,4 @@ void DetectModbusRegisterTests(void)
UtRegisterTest("DetectModbusTest13 - Testing a range of unit_id",
DetectModbusTest13);
}
#endif /* UNITTESTS */
#endif /* UNITTESTS */

Loading…
Cancel
Save