From 91cc2059f5566ca7d22557df7fe47860d93d0009 Mon Sep 17 00:00:00 2001 From: footpatch Date: Sun, 6 Feb 2022 06:17:38 -0500 Subject: [PATCH] Fix file descriptor leak in memtest_test_linux_anonymous_maps (#4241) when we fail opening `/proc`, we need to close the log file fd. --- src/debug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/debug.c b/src/debug.c index 146460646..305941586 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1764,7 +1764,10 @@ int memtest_test_linux_anonymous_maps(void) { if (!fd) return 0; fp = fopen("/proc/self/maps","r"); - if (!fp) return 0; + if (!fp) { + closeDirectLogFiledes(fd); + return 0; + } while(fgets(line,sizeof(line),fp) != NULL) { char *start, *end, *p = line;