Changeset 292950 in webkit
- Timestamp:
- Apr 17, 2022, 2:52:53 PM (3 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r292946 r292950 1 2022-04-16 Mark Lam <mark.lam@apple.com> 2 3 Harden JSObject::setPrototypeOf. 4 https://bugs.webkit.org/show_bug.cgi?id=239440 5 6 Reviewed by Yusuke Suzuki. 7 8 * runtime/JSObject.cpp: 9 (JSC::JSObject::setPrototypeDirect): 10 (JSC::JSObject::setPrototypeWithCycleCheck): 11 * runtime/JSObject.h: 12 * runtime/ObjectConstructor.cpp: 13 (JSC::objectConstructorSetPrototypeOf): 14 1 15 2022-04-16 Mark Lam <mark.lam@apple.com> 2 16 -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r292929 r292950 2 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 3 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 4 * Copyright (C) 2003-202 1Apple Inc. All rights reserved.4 * Copyright (C) 2003-2022 Apple Inc. All rights reserved. 5 5 * Copyright (C) 2007 Eric Seidel (eric@webkit.org) 6 6 * … … 65 65 const ASCIILiteral UnconfigurablePropertyChangeEnumerabilityError { "Attempting to change enumerable attribute of unconfigurable property."_s }; 66 66 const ASCIILiteral UnconfigurablePropertyChangeWritabilityError { "Attempting to change writable attribute of unconfigurable property."_s }; 67 const ASCIILiteral PrototypeValueCanOnlyBeAnObjectOrNullTypeError { "Prototype value can only be an object or null"_s }; 67 68 68 69 const ClassInfo JSObject::s_info = { "Object"_s, nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(JSObject) }; … … 1874 1875 void JSObject::setPrototypeDirect(VM& vm, JSValue prototype) 1875 1876 { 1876 ASSERT(prototype );1877 ASSERT(prototype.isObject() || prototype.isNull()); 1877 1878 if (prototype.isObject()) 1878 1879 asObject(prototype)->didBecomePrototype(); 1880 else if (UNLIKELY(!prototype.isNull())) // Conservative hardening. 1881 return; 1879 1882 1880 1883 if (structure()->hasMonoProto()) { … … 1926 1929 if (!isExtensible) 1927 1930 return typeError(globalObject, scope, shouldThrowIfCantSet, ReadonlyPropertyWriteError); 1931 1932 // Some clients would have already done this check because of the order of the check 1933 // specified in their respective specifications. However, we still do this check here 1934 // to document and enforce this invariant about the nature of prototype. 1935 if (UNLIKELY(!prototype.isObject() && !prototype.isNull())) 1936 return typeError(globalObject, scope, shouldThrowIfCantSet, PrototypeValueCanOnlyBeAnObjectOrNullTypeError); 1928 1937 1929 1938 JSValue nextPrototype = prototype; -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r292929 r292950 2 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 3 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 4 * Copyright (C) 2003-202 1Apple Inc. All rights reserved.4 * Copyright (C) 2003-2022 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 84 84 extern JS_EXPORT_PRIVATE const ASCIILiteral UnconfigurablePropertyChangeEnumerabilityError; 85 85 extern JS_EXPORT_PRIVATE const ASCIILiteral UnconfigurablePropertyChangeWritabilityError; 86 extern JS_EXPORT_PRIVATE const ASCIILiteral PrototypeValueCanOnlyBeAnObjectOrNullTypeError; 86 87 87 88 class JSFinalObject; -
trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp
r292929 r292950 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 3 * Copyright (C) 2008-202 1Apple Inc. All rights reserved.3 * Copyright (C) 2008-2022 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 161 161 JSValue protoValue = callFrame->argument(1); 162 162 if (!protoValue.isObject() && !protoValue.isNull()) 163 return throwVMTypeError(globalObject, scope, "Prototype value can only be an object or null"_s);163 return throwVMTypeError(globalObject, scope, PrototypeValueCanOnlyBeAnObjectOrNullTypeError); 164 164 165 165 JSObject* object = objectValue.toObject(globalObject);
Note:
See TracChangeset
for help on using the changeset viewer.