Fix JDWP crash when reporting exception
The exception's throw location may be null so we need to handle that
case. Also fixes a memset issue.
Bug: 17571297
(cherry picked from commit bbb63897d7f2d99219cb50721fe530521e08ddff)
Change-Id: Iedebb58f9460c5f04913c269200e51161bda1ba9
diff --git a/runtime/jdwp/jdwp_event.cc b/runtime/jdwp/jdwp_event.cc
index d61660b..7c8c63c 100644
--- a/runtime/jdwp/jdwp_event.cc
+++ b/runtime/jdwp/jdwp_event.cc
@@ -1125,12 +1125,19 @@
DCHECK(exception_object != nullptr);
DCHECK(pThrowLoc != nullptr);
DCHECK(pCatchLoc != nullptr);
- DCHECK(pThrowLoc->method != nullptr);
- DCHECK_EQ(pThrowLoc->method->IsStatic(), thisPtr == nullptr);
+ if (pThrowLoc->method != nullptr) {
+ DCHECK_EQ(pThrowLoc->method->IsStatic(), thisPtr == nullptr);
+ } else {
+ VLOG(jdwp) << "Unexpected: exception event with empty throw location";
+ }
ModBasket basket;
basket.pLoc = pThrowLoc;
- basket.locationClass = pThrowLoc->method->GetDeclaringClass();
+ if (pThrowLoc->method != nullptr) {
+ basket.locationClass = pThrowLoc->method->GetDeclaringClass();
+ } else {
+ basket.locationClass = nullptr;
+ }
basket.thread = Thread::Current();
basket.className = Dbg::GetClassName(basket.locationClass);
basket.exceptionClass = exception_object->GetClass();