[PATCH] nm: Fix file descriptor leak on dwfl_begin failure.
Mark Wielaard
mark@klomp.org
Sat Apr 3 17:54:41 GMT 2021
If dwfl_begin fails we won't use the dwfl_fd descriptor we just dupped.
Make sure to close on dwfl_begin failure to avoid the leak.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
src/ChangeLog | 4 ++++
src/nm.c | 2 ++
2 files changed, 6 insertions(+)
diff --git a/src/ChangeLog b/src/ChangeLog
index 300deb4f..0cea28e2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2021-04-03 Mark Wielaard <mark@klomp.org>
+
+ * nm.c (show_symbols): close dwfl_fd if dwfl_begin fails.
+
2021-04-03 Mark Wielaard <mark@klomp.org>
* unstrip.c (handle_output_dir_module): Free output_file when done.
diff --git a/src/nm.c b/src/nm.c
index fb761ef3..dc2186db 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -1308,6 +1308,8 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr,
dwfl_getmodules (dwfl, &getdbg_dwflmod, &get, 0);
}
}
+ else
+ close (dwfl_fd);
}
}
if (dbg != NULL)
--
2.18.4
More information about the Elfutils-devel
mailing list