Changeset 243246 in webkit
- Timestamp:
- Mar 20, 2019, 3:12:12 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/create-error-out-of-memory-rope-string.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/runtime/ExceptionHelpers.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/ExceptionHelpers.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r243191 r243246 1 2019-03-20 Tadeu Zagallo <tzagallo@apple.com> 2 3 JSC::createError needs to check for OOM in errorDescriptionForValue 4 https://bugs.webkit.org/show_bug.cgi?id=196032 5 <rdar://problem/46842740> 6 7 Reviewed by Mark Lam. 8 9 * stress/create-error-out-of-memory-rope-string.js: Added. 10 1 11 2019-03-19 Yusuke Suzuki <ysuzuki@apple.com> 2 12 -
trunk/Source/JavaScriptCore/ChangeLog
r243244 r243246 1 2019-03-20 Tadeu Zagallo <tzagallo@apple.com> 2 3 JSC::createError needs to check for OOM in errorDescriptionForValue 4 https://bugs.webkit.org/show_bug.cgi?id=196032 5 <rdar://problem/46842740> 6 7 Reviewed by Mark Lam. 8 9 We were missing exceptions checks at two levels: 10 - In errorDescriptionForValue, when the value is a string, we should 11 check that JSString::value returns a valid string, since we might run 12 out of memory if it is a rope and we need to resolve it. 13 - In createError, we should check for the result of errorDescriptionForValue 14 before concatenating it with the message provided by the caller. 15 16 * runtime/ExceptionHelpers.cpp: 17 (JSC::errorDescriptionForValue): 18 (JSC::createError): 19 * runtime/ExceptionHelpers.h: 20 1 21 2019-03-20 Devin Rousso <drousso@apple.com> 2 22 -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp
r242910 r243246 90 90 } 91 91 92 JSString* errorDescriptionForValue(ExecState* exec, JSValue v) 93 { 94 if (v.isString()) 95 return jsNontrivialString(exec, makeString('"', asString(v)->value(exec), '"')); 92 String errorDescriptionForValue(ExecState* exec, JSValue v) 93 { 94 if (v.isString()) { 95 String string = asString(v)->value(exec); 96 if (!string) 97 return string; 98 return tryMakeString('"', string, '"'); 99 } 100 96 101 if (v.isSymbol()) 97 return jsNontrivialString(exec, asSymbol(v)->descriptiveString());102 return asSymbol(v)->descriptiveString(); 98 103 if (v.isObject()) { 99 104 VM& vm = exec->vm(); … … 101 106 JSObject* object = asObject(v); 102 107 if (object->methodTable(vm)->getCallData(object, callData) != CallType::None) 103 return vm.smallStrings.functionString() ;104 return jsString(exec, JSObject::calculatedClassName(object));105 } 106 return v.toString(exec) ;108 return vm.smallStrings.functionString()->value(exec); 109 return JSObject::calculatedClassName(object); 110 } 111 return v.toString(exec)->value(exec); 107 112 } 108 113 … … 270 275 auto scope = DECLARE_CATCH_SCOPE(vm); 271 276 272 String errorMessage = tryMakeString(errorDescriptionForValue(exec, value)->value(exec), ' ', message); 273 if (errorMessage.isNull()) 277 String valueDescription = errorDescriptionForValue(exec, value); 278 if (!valueDescription) 279 return createOutOfMemoryError(exec); 280 String errorMessage = tryMakeString(valueDescription, ' ', message); 281 if (!errorMessage) 274 282 return createOutOfMemoryError(exec); 275 283 scope.assertNoException(); -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h
r242596 r243246 55 55 JSObject* createNotAFunctionError(ExecState*, JSValue); 56 56 JSObject* createErrorForInvalidGlobalAssignment(ExecState*, const String&); 57 JSString*errorDescriptionForValue(ExecState*, JSValue);57 String errorDescriptionForValue(ExecState*, JSValue); 58 58 59 59 JS_EXPORT_PRIVATE Exception* throwOutOfMemoryError(ExecState*, ThrowScope&);
Note:
See TracChangeset
for help on using the changeset viewer.