]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
nm: Fix file descriptor leak on dwfl_begin failure.
authorMark Wielaard <mark@klomp.org>
Sat, 3 Apr 2021 17:52:38 +0000 (19:52 +0200)
committerMark Wielaard <mark@klomp.org>
Tue, 13 Apr 2021 12:45:34 +0000 (14:45 +0200)
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
src/nm.c

index 300deb4f866e278d3361c56bcf5d43cbd5bbe00e..0cea28e2dde50adff95eb2f70439d9264ab2e65c 100644 (file)
@@ -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.
index fb761ef3d8631176a678fd3d8c4dc86a6af762e3..dc2186db65cccae508fc844f003cacc381e273b6 100644 (file)
--- 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)