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 <[email protected]>
---
libdwfl/link_map.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c
index 5f9341318bde..1f4fbe462a08 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;
--
2.54.0