Free buf before exiting if strtok fails. Fixes a RESOURCE_LEAK error (CWE-772) Signed-off-by: Jerome Marchand <jmarchan@xxxxxxxxxx> --- lib/trace-cmd/trace-input.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index 2cf0d1c1..3284dbd4 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -666,6 +666,7 @@ static int regex_event_buf(const char *file, int size, regex_t *epreg) line = strtok(buf, "\n"); if (!line) { tracecmd_warning("No newline found in '%s'", buf); + free(buf); return 0; } /* skip name if it is there */ -- 2.44.0