In show_error() the pointer p is used for several functions. At some point it is used to contain the error log file. It's not freed before being replaced by the result of read_file(path), which is not freed either. Free p in both case. Fixes a RESOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx> --- tracecmd/trace-record.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index f05a58d1..3e29f922 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -2364,13 +2364,16 @@ static void show_error(const char *file, const char *type) goto read_file; } read_error_log(p); + free(p); goto out; } read_file: p = read_file(path); - if (p) + if (p) { printf("%s", p); + free(p); + } out: printf("Failed %s of %s\n", type, file); -- 2.44.0