From 3557d7b8859066f085b72e4895797707288c2688 Mon Sep 17 00:00:00 2001 From: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com> Date: Sat, 1 Feb 2025 11:51:08 -0600 Subject: [PATCH] Fix handling of DW_DLV_ERROR --- src/symbols/dwarf/dwarf.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/symbols/dwarf/dwarf.hpp b/src/symbols/dwarf/dwarf.hpp index 18ac4e3..7d60948 100644 --- a/src/symbols/dwarf/dwarf.hpp +++ b/src/symbols/dwarf/dwarf.hpp @@ -27,10 +27,11 @@ namespace libdwarf { [[noreturn]] inline void handle_dwarf_error(Dwarf_Debug dbg, Dwarf_Error error) { Dwarf_Unsigned ev = dwarf_errno(error); - char* msg = dwarf_errmsg(error); - (void)dbg; - // dwarf_dealloc_error(dbg, error); - throw internal_error("dwarf error {} {}", ev, msg); + const char* msg = dwarf_errmsg(error); + // dwarf_dealloc_error deallocates the message + auto error_message = microfmt::format("dwarf error {} {}", ev, msg); + dwarf_dealloc_error(dbg, error); + throw internal_error(std::move(error_message)); } struct die_object {