Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index e72abc87de14ecf523fe5d892b694287db3cbc26..46c923d01e2d5b3ffddc1c11c3e092a5638af1f4 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -3913,11 +3913,10 @@ Local<Object> v8::Object::FindInstanceInPrototypeChain( |
i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this), |
i::kStartAtReceiver); |
auto tmpl_info = *Utils::OpenHandle(*tmpl); |
- while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { |
+ while (!tmpl_info->IsTemplateFor(iter.GetCurrent<i::JSObject>())) { |
iter.Advance(); |
- if (iter.IsAtEnd()) { |
- return Local<Object>(); |
- } |
+ if (iter.IsAtEnd()) return Local<Object>(); |
+ if (!iter.GetCurrent()->IsJSObject()) return Local<Object>(); |
} |
// IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here. |
return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); |
@@ -5810,7 +5809,7 @@ Local<v8::Function> FunctionTemplate::GetFunction() { |
bool FunctionTemplate::HasInstance(v8::Local<v8::Value> value) { |
auto self = Utils::OpenHandle(this); |
auto obj = Utils::OpenHandle(*value); |
- return self->IsTemplateFor(*obj); |
+ return obj->IsJSObject() && self->IsTemplateFor(i::JSObject::cast(*obj)); |
} |