summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-04-03 19:52:38 +0200
committerMark Wielaard <mark@klomp.org>2021-04-13 14:45:34 +0200
commit879513aba0b765c5552fc371c7fc55df4135661e (patch)
treed5066b003bd6d1d21738c1f74a9c7e2faefb844d
parent1261691accb3f224ebbaef438a641273c4c3c49f (diff)
downloadelfutils-879513aba0b765c5552fc371c7fc55df4135661e.tar.gz
nm: Fix file descriptor leak on dwfl_begin failure.
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>
-rw-r--r--src/ChangeLog4
-rw-r--r--src/nm.c2
2 files changed, 6 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 300deb4f..0cea28e2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
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.
2021-04-03 Mark Wielaard <mark@klomp.org>
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)