summaryrefslogtreecommitdiffstats
path: root/runtime/mirror
diff options
context:
space:
mode:
authorDmitry Petrochenko <dmitry.petrochenko@intel.com>2014-10-01 13:31:58 +0700
committerDmitry Petrochenko <dmitry.petrochenko@intel.com>2014-10-02 12:06:38 +0700
commit6d7729d6ae8b2ac3800e92092d61390ce4e3b6d7 (patch)
tree6952c8a01e0b071b404a78b91fc536b89a22930c /runtime/mirror
parent8283e079a209e81caafd123a12a525922368fd34 (diff)
downloadart-6d7729d6ae8b2ac3800e92092d61390ce4e3b6d7.zip
art-6d7729d6ae8b2ac3800e92092d61390ce4e3b6d7.tar.gz
art-6d7729d6ae8b2ac3800e92092d61390ce4e3b6d7.tar.bz2
Fix OOM throwing if it happens in finalizer reference
The Class::Alloc should return null if OOM happened during adding finalizer reference, even if finalizable object is allocated succesfully. Change-Id: I66c1cdda50228bf1302839785ce4d4889b676f5b Signed-off-by: Dmitry Petrochenko <dmitry.petrochenko@intel.com> Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
Diffstat (limited to 'runtime/mirror')
-rw-r--r--runtime/mirror/class-inl.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 3d3ae16..661de68 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -553,6 +553,10 @@ inline Object* Class::Alloc(Thread* self, gc::AllocatorType allocator_type) {
allocator_type, VoidFunctor());
if (add_finalizer && LIKELY(obj != nullptr)) {
heap->AddFinalizerReference(self, &obj);
+ if (UNLIKELY(self->IsExceptionPending())) {
+ // Failed to allocate finalizer reference, it means that whole allocation failed
+ obj = nullptr;
+ }
}
return obj;
}