]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf.c: Close dwfl if dwfl_report_offline fails
authorAaron Merey <amerey@redhat.com>
Mon, 8 Sep 2025 02:17:29 +0000 (22:17 -0400)
committerAaron Merey <amerey@redhat.com>
Tue, 9 Sep 2025 13:37:25 +0000 (09:37 -0400)
Within create_dwfl, if dwfl_begin is successful but dwfl_report_offline
fails, the dwfl * pointer being reported is reset to NULL without calling
dwfl_end, causing a memory leak.

Update create_dwfl to call dwfl_end in this case, preventing the leak.

Signed-off-by: Aaron Merey <amerey@redhat.com>
src/readelf.c

index 6b886c59287e507840f1da77967945456c21e8ac..138ded6b0db3e71862b047821b04832a80755745 100644 (file)
@@ -978,6 +978,7 @@ create_dwfl (int fd, const char *fname)
        error (0, 0, _("failed reading '%s': %s"),
               fname, dwfl_errmsg (-1));
       close (dwfl_fd);         /* Consumed on success, not on failure.  */
+      dwfl_end (dwfl);
       dwfl = NULL;
     }
   else