From d1189a6c75db98d9a62511d7f6ed90d9623cfaf0 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 27 Jul 2013 22:55:51 -0400 Subject: [PATCH] Debugger: DwarfImageDebugInfo - fix potential crash. If the subroutine address in question required us to in a different image, that lookup would overwrite our pointer to the starting image. If said lookup then also failed, a crash would occur when performing operations to look up the next return value, since the image pointer would then be NULL. --- src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp index 58e478ace2..da83cf8d16 100644 --- a/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp +++ b/src/apps/debugger/debug_info/DwarfImageDebugInfo.cpp @@ -1097,14 +1097,15 @@ DwarfImageDebugInfo::_CreateReturnValues(ReturnValueInfoList* returnValueInfos, Image* image, StackFrame* frame, DwarfStackFrameDebugInfo& factory) { for (int32 i = 0; i < returnValueInfos->CountItems(); i++) { + Image* targetImage = image; ReturnValueInfo* valueInfo = returnValueInfos->ItemAt(i); target_addr_t subroutineAddress = valueInfo->SubroutineAddress(); CpuState* subroutineState = valueInfo->State(); - if (!image->ContainsAddress(subroutineAddress)) { + if (!targetImage->ContainsAddress(subroutineAddress)) { // our current image doesn't contain the target function, // locate the one which does. - image = image->GetTeam()->ImageByAddress(subroutineAddress); - if (image == NULL) { + targetImage = image->GetTeam()->ImageByAddress(subroutineAddress); + if (targetImage == NULL) { // nothing we can do, try the next entry (if any) continue; }