From f52aee04b3839b5c2bcfb2a5114b698e39925df2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 20 Feb 2021 07:38:06 -0500 Subject: [PATCH] lib: Free memory leak in error path in clippy When running clippy, the main function in it's error path could leak the memory pointed to by name. Fix this. This was/is reported by clang SA. Signed-off-by: Donald Sharp --- lib/clippy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/clippy.c b/lib/clippy.c index b52c48ec92..6223697ae9 100644 --- a/lib/clippy.c +++ b/lib/clippy.c @@ -68,6 +68,8 @@ int main(int argc, char **argv) fp = fopen(pyfile, "r"); if (!fp) { fprintf(stderr, "%s: %s\n", pyfile, strerror(errno)); + + free(name); return 1; } } else { @@ -86,6 +88,8 @@ int main(int argc, char **argv) if (PyRun_AnyFile(fp, pyfile)) { if (PyErr_Occurred()) PyErr_Print(); + + free(name); return 1; } Py_Finalize(); -- 2.39.5