From: Mark Wielaard Date: Mon, 4 May 2026 15:26:14 +0000 (+0200) Subject: libdwfl: Fix out of memory handling in link_map.c report_r_debug X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=cf2c8589b4eccef7f2ae11783dd6996420cb6e67;p=thirdparty%2Felfutils.git libdwfl: Fix out of memory handling in link_map.c report_r_debug 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 --- diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 5f934131..1f4fbe46 100644 --- a/libdwfl/link_map.c +++ b/libdwfl/link_map.c @@ -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;