From 124ba8aec7d5db62c32f1293b90b9701064c0317 Mon Sep 17 00:00:00 2001 From: meme Date: Tue, 25 Aug 2020 13:49:12 -0400 Subject: [PATCH] Check `status` of `__cxa_demangle` --- VTIL-Common/io/formatting.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/VTIL-Common/io/formatting.hpp b/VTIL-Common/io/formatting.hpp index e598658..0e34996 100644 --- a/VTIL-Common/io/formatting.hpp +++ b/VTIL-Common/io/formatting.hpp @@ -83,7 +83,14 @@ namespace vtil::format #ifdef __GNUG__ int status; char* demangled_name = abi::__cxa_demangle( in.data(), nullptr, nullptr, &status ); - in = demangled_name; + // If demangling succeeds, set the name. + // + if ( status == 0 ) + { + in = demangled_name; + } + // Free unconditionally. + // free( demangled_name ); #endif @@ -352,4 +359,4 @@ namespace vtil using format::CustomStringConvertible; using format::StdStringConvertible; using format::StringConvertible; -}; \ No newline at end of file +};