From 0725c6fbd58b3d40ffefdb319121a29ba4168517 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Tue, 19 Jul 2022 18:27:50 -0400 Subject: Make DebugInfo::parse failable --- debuginfo.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'debuginfo.cpp') diff --git a/debuginfo.cpp b/debuginfo.cpp index fb10039e..c67582cb 100644 --- a/debuginfo.cpp +++ b/debuginfo.cpp @@ -363,10 +363,21 @@ string DebugInfoParser::GetName() const Ref DebugInfoParser::Parse(Ref view, Ref existingDebugInfo) const { + BNDebugInfo* info = nullptr; if (existingDebugInfo) - return new DebugInfo( - BNNewDebugInfoReference(BNParseDebugInfo(m_object, view->GetObject(), existingDebugInfo->GetObject()))); - return new DebugInfo(BNParseDebugInfo(m_object, view->GetObject(), nullptr)); + { + info = BNParseDebugInfo(m_object, view->GetObject(), existingDebugInfo->GetObject()); + if (!info) + return nullptr; + info = BNNewDebugInfoReference(info); + } + else + { + info = BNParseDebugInfo(m_object, view->GetObject(), nullptr); + if (!info) + return nullptr; + } + return new DebugInfo(info); } @@ -388,10 +399,10 @@ bool CustomDebugInfoParser::IsValidCallback(void* ctxt, BNBinaryView* view) } -void CustomDebugInfoParser::ParseCallback(void* ctxt, BNDebugInfo* debugInfo, BNBinaryView* view) +bool CustomDebugInfoParser::ParseCallback(void* ctxt, BNDebugInfo* debugInfo, BNBinaryView* view) { CustomDebugInfoParser* parser = (CustomDebugInfoParser*)ctxt; - parser->ParseInfo(new DebugInfo(debugInfo), new BinaryView(view)); + return parser->ParseInfo(new DebugInfo(debugInfo), new BinaryView(view)); } -- cgit v1.3.1