Free func_list if strdup() fails. Fixes a RESSOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx> --- src/tracefs-tools.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c index 8e7b46d..74cfe91 100644 --- a/src/tracefs-tools.c +++ b/src/tracefs-tools.c @@ -559,8 +559,10 @@ static int add_func_str(struct func_list ***next_func_ptr, const char *func) if (!func_list) return -1; func_list->func = strdup(func); - if (!func_list->func) + if (!func_list->func) { + free(func_list); return -1; + } *next_func = func_list; return 0; } -- 2.44.0