Guard against nullptr active frame
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Thu, 24 Aug 2017 17:31:36 +0000 (20:31 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 13 Nov 2017 19:22:40 +0000 (22:22 +0300)
src/debug/netcoredbg/breakpoints.cpp
src/debug/netcoredbg/commands.cpp
src/debug/netcoredbg/main.cpp
src/debug/netcoredbg/modules.cpp

index 03640db706932f7db7e9638b2e3a93c7189f35f4..c9070734ee769d4aa240256afd5aeb00838a8d65 100644 (file)
@@ -91,6 +91,8 @@ HRESULT HitBreakpoint(ICorDebugThread *pThread, ULONG32 &id, ULONG32 &times)
 
     ToRelease<ICorDebugFrame> pFrame;
     IfFailRet(pThread->GetActiveFrame(&pFrame));
+    if (pFrame == nullptr)
+        return E_FAIL;
     IfFailRet(pFrame->GetFunctionToken(&methodToken));
 
     IfFailRet(Modules::GetFrameLocation(pFrame, ilOffset, sp));
index 9615faee83c3254197a5297d9ec226521f926d0b..0991555d02bcf3e2f99884133dbffe9decc38040 100644 (file)
@@ -368,6 +368,8 @@ HRESULT Debugger::HandleCommand(std::string command,
 
         ToRelease<ICorDebugFrame> pFrame;
         IfFailRet(pThread->GetActiveFrame(&pFrame));
+        if (pFrame == nullptr)
+            return E_FAIL;
         int childStart = 0;
         int childEnd = INT_MAX;
         StripArgs(args);
index 360326e000c6fd5cc8bb6e2b8a10020e1b971af8..b4f0abb5beeb0b364c113efb837a3c3c2a918366 100644 (file)
@@ -277,13 +277,15 @@ static HRESULT GetExceptionInfo(ICorDebugThread *pThread,
 {
     HRESULT Status;
 
-    ToRelease<ICorDebugFrame> pFrame;
-    IfFailRet(pThread->GetActiveFrame(&pFrame));
     ToRelease<ICorDebugValue> pExceptionValue;
     IfFailRet(pThread->GetCurrentException(&pExceptionValue));
 
     TypePrinter::GetTypeOfValue(pExceptionValue, excType);
 
+    ToRelease<ICorDebugFrame> pFrame;
+    IfFailRet(pThread->GetActiveFrame(&pFrame));
+    if (pFrame == nullptr)
+        return E_FAIL;
     ToRelease<ICorDebugFunction> pFunc;
     IfFailRet(pFrame->GetFunction(&pFunc));
 
@@ -378,7 +380,7 @@ public:
 
             std::string output;
             ToRelease<ICorDebugFrame> pFrame;
-            if (SUCCEEDED(pThread->GetActiveFrame(&pFrame)))
+            if (SUCCEEDED(pThread->GetActiveFrame(&pFrame)) && pFrame != nullptr)
                 PrintFrameLocation(pFrame, output);
 
             DWORD threadId = 0;
@@ -401,7 +403,7 @@ public:
             std::string output;
             ToRelease<ICorDebugFrame> pFrame;
             HRESULT Status = S_FALSE;
-            if (SUCCEEDED(pThread->GetActiveFrame(&pFrame)))
+            if (SUCCEEDED(pThread->GetActiveFrame(&pFrame)) && pFrame != nullptr)
                 Status = PrintFrameLocation(pFrame, output);
 
             const bool no_source = Status == S_FALSE;
@@ -435,7 +437,7 @@ public:
         {
             std::string output;
             ToRelease<ICorDebugFrame> pFrame;
-            if (SUCCEEDED(pThread->GetActiveFrame(&pFrame)))
+            if (SUCCEEDED(pThread->GetActiveFrame(&pFrame)) && pFrame != nullptr)
                 PrintFrameLocation(pFrame, output);
 
             DWORD threadId = 0;
index d8d9943ad88c16b8b26cd976e3d7e239aa57f9f6..b3cfd21e73841ef97499792d2171381efa45618d 100644 (file)
@@ -197,6 +197,8 @@ HRESULT GetStepRangeFromCurrentIP(ICorDebugThread *pThread, COR_DEBUG_STEP_RANGE
     HRESULT Status;
     ToRelease<ICorDebugFrame> pFrame;
     IfFailRet(pThread->GetActiveFrame(&pFrame));
+    if (pFrame == nullptr)
+        return E_FAIL;
 
     mdMethodDef methodToken;
     IfFailRet(pFrame->GetFunctionToken(&methodToken));