Skip to content

Commit bda45b5

Browse files
cristiancavalliofrobots
authored andcommitted
deps: backport 5c8cb16 from upstream V8
Original Commit Message: [ic] Don't call LookupIterator::GetStoreTarget() when receiver is not a JSReceiver. BUG=chromium:619166,chromium:625155 Review-Url: https://codereview.chromium.org/2175273002 Cr-Commit-Position: refs/heads/master@{#38018} PR-URL: #9422 Reviewed-By: bnoordhuis - Ben Noordhuis <[email protected]> Reviewed-By: jasnell - James M Snell <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
1 parent 39b4a1c commit bda45b5

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 5
1212
#define V8_MINOR_VERSION 1
1313
#define V8_BUILD_NUMBER 281
14-
#define V8_PATCH_LEVEL 85
14+
#define V8_PATCH_LEVEL 86
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/lookup.h

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ class LookupIterator final BASE_EMBEDDED {
179179
Handle<Object> GetReceiver() const { return receiver_; }
180180

181181
Handle<JSObject> GetStoreTarget() const {
182+
DCHECK(receiver->IsJSObject());
182183
if (receiver_->IsJSGlobalProxy()) {
183184
Map* map = JSGlobalProxy::cast(*receiver_)->map();
184185
if (map->has_hidden_prototype()) {

deps/v8/src/objects.cc

+16-1
Original file line numberDiff line numberDiff line change
@@ -4214,11 +4214,20 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
42144214
return JSProxy::SetProperty(it->GetHolder<JSProxy>(), it->GetName(),
42154215
value, it->GetReceiver(), language_mode);
42164216

4217-
case LookupIterator::INTERCEPTOR:
4217+
case LookupIterator::INTERCEPTOR: {
4218+
Handle<Map> store_target_map;
4219+
if (it->GetReceiver()->IsJSObject()) {
4220+
store_target_map = handle(it->GetStoreTarget()->map(), it->isolate());
4221+
}
42184222
if (it->HolderIsReceiverOrHiddenPrototype()) {
42194223
Maybe<bool> result =
42204224
JSObject::SetPropertyWithInterceptor(it, should_throw, value);
42214225
if (result.IsNothing() || result.FromJust()) return result;
4226+
Utils::ApiCheck(store_target_map.is_null() ||
4227+
*store_target_map == it->GetStoreTarget()->map(),
4228+
it->IsElement() ? "v8::IndexedPropertySetterCallback"
4229+
: "v8::NamedPropertySetterCallback",
4230+
"Interceptor silently changed store target.");
42224231
} else {
42234232
Maybe<PropertyAttributes> maybe_attributes =
42244233
JSObject::GetPropertyAttributesWithInterceptor(it);
@@ -4227,10 +4236,16 @@ Maybe<bool> Object::SetPropertyInternal(LookupIterator* it,
42274236
if ((maybe_attributes.FromJust() & READ_ONLY) != 0) {
42284237
return WriteToReadOnlyProperty(it, value, should_throw);
42294238
}
4239+
Utils::ApiCheck(store_target_map.is_null() ||
4240+
*store_target_map == it->GetStoreTarget()->map(),
4241+
it->IsElement() ? "v8::IndexedPropertySetterCallback"
4242+
: "v8::NamedPropertySetterCallback",
4243+
"Interceptor silently changed store target.");
42304244
*found = false;
42314245
return Nothing<bool>();
42324246
}
42334247
break;
4248+
}
42344249

42354250
case LookupIterator::ACCESSOR: {
42364251
if (it->IsReadOnly()) {

deps/v8/test/cctest/test-api-interceptors.cc

+19
Original file line numberDiff line numberDiff line change
@@ -3245,6 +3245,25 @@ THREADED_TEST(Regress149912) {
32453245
CompileRun("Number.prototype.__proto__ = new Bug; var x = 0; x.foo();");
32463246
}
32473247

3248+
THREADED_TEST(Regress625155) {
3249+
LocalContext context;
3250+
v8::HandleScope scope(context->GetIsolate());
3251+
Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
3252+
AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter);
3253+
context->Global()
3254+
->Set(context.local(), v8_str("Bug"),
3255+
templ->GetFunction(context.local()).ToLocalChecked())
3256+
.FromJust();
3257+
CompileRun(
3258+
"Number.prototype.__proto__ = new Bug;"
3259+
"var x;"
3260+
"x = 0xdead;"
3261+
"x.boom = 0;"
3262+
"x = 's';"
3263+
"x.boom = 0;"
3264+
"x = 1.5;"
3265+
"x.boom = 0;");
3266+
}
32483267

32493268
THREADED_TEST(Regress125988) {
32503269
v8::HandleScope scope(CcTest::isolate());

0 commit comments

Comments
 (0)