Changeset 239355 in webkit
- Timestamp:
- Dec 18, 2018 2:24:33 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r239354 r239355 1 2018-12-18 Mark Lam <mark.lam@apple.com> 2 3 JSON.stringify() should throw OOM on StringBuilder overflows. 4 https://bugs.webkit.org/show_bug.cgi?id=192822 5 <rdar://problem/46670577> 6 7 Reviewed by Saam Barati. 8 9 * stress/json-stringify-string-builder-overflow.js: Added. 10 1 11 2018-12-18 Ross Kirsling <ross.kirsling@sony.com> 2 12 -
trunk/Source/JavaScriptCore/ChangeLog
r239354 r239355 1 2018-12-18 Mark Lam <mark.lam@apple.com> 2 3 JSON.stringify() should throw OOM on StringBuilder overflows. 4 https://bugs.webkit.org/show_bug.cgi?id=192822 5 <rdar://problem/46670577> 6 7 Reviewed by Saam Barati. 8 9 * runtime/JSONObject.cpp: 10 (JSC::Stringifier::stringify): 11 (JSC::Stringifier::appendStringifiedValue): 12 (JSC::Stringifier::Holder::appendNextProperty): 13 1 14 2018-12-18 Ross Kirsling <ross.kirsling@sony.com> 2 15 -
trunk/Source/JavaScriptCore/runtime/JSONObject.cpp
r237577 r239355 270 270 if (isCallableReplacer()) { 271 271 object = constructEmptyObject(m_exec); 272 RETURN_IF_EXCEPTION(scope, js Null());272 RETURN_IF_EXCEPTION(scope, jsUndefined()); 273 273 object->putDirect(vm, vm.propertyNames->emptyIdentifier, value); 274 274 } … … 277 277 Holder root(Holder::RootHolder, object); 278 278 auto stringifyResult = appendStringifiedValue(result, value, root, emptyPropertyName); 279 EXCEPTION_ASSERT(!scope.exception() || (stringifyResult != StringifySucceeded)); 279 RETURN_IF_EXCEPTION(scope, jsUndefined()); 280 if (UNLIKELY(result.hasOverflowed())) { 281 throwOutOfMemoryError(m_exec, scope); 282 return jsUndefined(); 283 } 280 284 if (UNLIKELY(stringifyResult != StringifySucceeded)) 281 285 return jsUndefined(); 282 283 286 RELEASE_AND_RETURN(scope, jsString(m_exec, result.toString())); 284 287 } … … 360 363 RETURN_IF_EXCEPTION(scope, StringifyFailed); 361 364 builder.appendQuotedJSONString(string); 362 if (UNLIKELY(builder.hasOverflowed())) {363 throwOutOfMemoryError(m_exec, scope);364 return StringifyFailed;365 }366 365 return StringifySucceeded; 367 366 } … … 392 391 } 393 392 393 if (UNLIKELY(builder.hasOverflowed())) 394 return StringifyFailed; 395 394 396 // Handle cycle detection, and put the holder on the stack. 395 397 for (unsigned i = 0; i < m_holderStack.size(); i++) { … … 411 413 RETURN_IF_EXCEPTION(scope, StringifyFailed); 412 414 RETURN_IF_EXCEPTION(scope, StringifyFailed); 415 if (UNLIKELY(builder.hasOverflowed())) 416 return StringifyFailed; 413 417 m_holderStack.removeLast(); 414 418 m_objectStack.removeLast(); … … 494 498 stringifier.indent(); 495 499 } 500 if (UNLIKELY(builder.hasOverflowed())) 501 return false; 496 502 497 503 // Last time through, finish up and return false.
Note: See TracChangeset
for help on using the changeset viewer.