From 3e03788ba80c94888d9e78bf1c8f62fff42353b8 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 10 May 2024 14:10:25 +0200 Subject: [PATCH] isotest: Fix fd leak Error: RESOURCE_LEAK (CWE-772): [#def65] [important] tools/isotest.c:923:4: open_fn: Returning handle opened by "open_file". tools/isotest.c:923:4: var_assign: Assigning: "fd" = handle returned from "open_file(altername)". tools/isotest.c:953:3: leaked_handle: Handle variable "fd" going out of scope leaks the handle. 951| 952| free(sk_arr); 953|-> return; 954| } 955| --- tools/isotest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/isotest.c b/tools/isotest.c index ddace0da3..58293133a 100644 --- a/tools/isotest.c +++ b/tools/isotest.c @@ -950,6 +950,8 @@ static void send_mode(char *filename, char *peer, int i, bool repeat) close(sk_arr[i]); free(sk_arr); + if (fd >= 0) + close(fd); return; } -- 2.47.3