Fix getExceptionMessage().
dvmAddTrackedAlloc() doesn't like NULL objects.
Bug 3023981.
Change-Id: I181e4dab841b063d9e2f450292732d808e70aaba
diff --git a/vm/Exception.c b/vm/Exception.c
index 35151f2..ddb84e5 100644
--- a/vm/Exception.c
+++ b/vm/Exception.c
@@ -1261,7 +1261,8 @@
dvmCallMethod(self, getMessageMethod, exception, &result);
messageStr = (StringObject*) result.l;
- dvmAddTrackedAlloc((Object*) messageStr, self);
+ if (messageStr != NULL)
+ dvmAddTrackedAlloc((Object*) messageStr, self);
dvmChangeStatus(self, oldStatus);
} else {
diff --git a/vm/alloc/Alloc.c b/vm/alloc/Alloc.c
index 4dcd91c..a897c67 100644
--- a/vm/alloc/Alloc.c
+++ b/vm/alloc/Alloc.c
@@ -247,6 +247,8 @@
* We could do this per-thread or globally. If it's global we don't have
* to do the thread lookup but we do have to synchronize access to the list.
*
+ * "obj" must not be NULL.
+ *
* NOTE: "obj" is not a fully-formed object; in particular, obj->clazz will
* usually be NULL since we're being called from dvmMalloc().
*/
@@ -255,6 +257,7 @@
if (self == NULL)
self = dvmThreadSelf();
+ assert(obj != NULL);
assert(self != NULL);
if (!dvmAddToReferenceTable(&self->internalLocalRefTable, obj)) {
LOGE("threadid=%d: unable to add %p to internal ref table\n",