Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: gin/wrappable.cc

Issue 184253004: gin: Bug fix: Fix CreateHandle to return an emtpy handle in some extreme cases (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bug fix: remove an extra include Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gin/handle.h ('k') | gin/wrappable_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/wrappable.cc
diff --git a/gin/wrappable.cc b/gin/wrappable.cc
index 8d41ce06c4dfc4b5abb0a08b50f5ac84929777c2..a330fefc8e89bb7071c7d592bdb708adc74ec1a7 100644
--- a/gin/wrappable.cc
+++ b/gin/wrappable.cc
@@ -44,6 +44,14 @@ v8::Handle<v8::Object> WrappableBase::GetWrapperImpl(v8::Isolate* isolate,
}
CHECK_EQ(kNumberOfInternalFields, templ->InternalFieldCount());
v8::Handle<v8::Object> wrapper = templ->NewInstance();
+ // |wrapper| may be empty in some extreme cases, e.g., when
+ // Object.prototype.constructor is overwritten.
+ if (wrapper.IsEmpty()) {
+ // The current wrappable object will be no longer managed by V8. Delete this
+ // now.
+ delete this;
+ return wrapper;
+ }
wrapper->SetAlignedPointerInInternalField(kWrapperInfoIndex, info);
wrapper->SetAlignedPointerInInternalField(kEncodedValueIndex, this);
wrapper_.Reset(isolate, wrapper);
« no previous file with comments | « gin/handle.h ('k') | gin/wrappable_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698