If allocating r_debug_info_module fails, report_r_debug called
release_buffer but ignored its return value and went on to write to
the NULL pointer. Return -1 like the other error paths.

Signed-off-by: mohammed mustafa <[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 06d85eb6..4a15044d 100644
--- a/libdwfl/link_map.c
+++ b/libdwfl/link_map.c
@@ -393,8 +393,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.53.0

Reply via email to