report:
HANDLE_LEAK The handle 'out' is created at `out = fopen(newname, "w");` 
by calling function 'fopen' and lost at `return 1;`
Corrections explained:
Added fclose(out) before returning from the function when out_h fails to open.
This ensures that the file handle 'out' is properly closed, preventing resource 
leaks.

Triggers found by static analyzer Svace.

Signed-off-by: Anton Moryakov <ant.v.morya...@gmail.com>

---
 scripts/kconfig/confdata.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 249a3195e..c5547d43a 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -375,6 +375,7 @@ int conf_write(const char *name)
        if (!name) {
                out_h = fopen(".tmpconfig.h", "w");
                if (!out_h)
+                       fclose(out);
                        return 1;
                file_write_dep(NULL);
        }
-- 
2.30.2

_______________________________________________
busybox mailing list
busybox@busybox.net
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to