]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdwfl: Fix out of memory handling in link_map.c report_r_debug
authorMark Wielaard <mark@klomp.org>
Mon, 4 May 2026 15:26:14 +0000 (17:26 +0200)
committerMark Wielaard <mark@klomp.org>
Mon, 4 May 2026 18:44:14 +0000 (20:44 +0200)
In report_r_debug we don't fully handle an out of memory condition
when trying to allocate memory for the r_debug_info_module struct.
Deallocated allocated buffers and return -1 immediately instead of
trying to continue.

* libdwfl/link_map.c (report_r_debug): Call release_buffer
with -1 and return on malloc failure.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdwfl/link_map.c

index 5f9341318bde93744d3e42ad88e9843a9077bf0e..1f4fbe462a0848f75cdac4083f0e63a0e6ad1f58 100644 (file)
@@ -405,8 +405,8 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata,
          r_debug_info_module = malloc (sizeof (*r_debug_info_module)
                                        + strlen (name1) + 1);
          if (unlikely (r_debug_info_module == NULL))
-           release_buffer (&memory_closure, &buffer,
-                            &buffer_available, result);
+           return release_buffer (&memory_closure, &buffer,
+                                  &buffer_available, -1);
          r_debug_info_module->fd = -1;
          r_debug_info_module->elf = NULL;
          r_debug_info_module->l_ld = l_ld;