From 6f9bba703e75fb68bd1acf360ff652d94c1d1a59 Mon Sep 17 00:00:00 2001 From: markj Date: Tue, 4 Feb 2020 21:15:29 +0000 Subject: [PATCH] libdwarf: Fix a memory leak in _dwarf_frame_section_init(). If frame length validation failed we would leak memory. CID: 1193366 MFC after: 1 week Sponsored by: The FreeBSD Foundation --- contrib/elftoolchain/libdwarf/libdwarf_frame.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/elftoolchain/libdwarf/libdwarf_frame.c b/contrib/elftoolchain/libdwarf/libdwarf_frame.c index cfa69714b302..9c2a623b43d0 100644 --- a/contrib/elftoolchain/libdwarf/libdwarf_frame.c +++ b/contrib/elftoolchain/libdwarf/libdwarf_frame.c @@ -468,9 +468,9 @@ _dwarf_frame_section_init(Dwarf_Debug dbg, Dwarf_FrameSec *frame_sec, if (length > ds->ds_size - offset || (length == 0 && !eh_frame)) { - DWARF_SET_ERROR(dbg, error, - DW_DLE_DEBUG_FRAME_LENGTH_BAD); - return (DW_DLE_DEBUG_FRAME_LENGTH_BAD); + ret = DW_DLE_DEBUG_FRAME_LENGTH_BAD; + DWARF_SET_ERROR(dbg, error, ret); + goto fail_cleanup; } /* Check terminator for .eh_frame */