Changeset 56021 in webkit
- Timestamp:
- Mar 15, 2010 3:59:45 PM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r56015 r56021 1 2010-03-15 Gavin Barraclough <barraclough@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 https://bugs.webkit.org/show_bug.cgi?id=35843 6 Re-land reverted fix to JSString::getIndex() 7 8 Calling getIndex() on a JSString in rope form may result in a JSException being thrown 9 if there is insuficient memory so value(exec) returns UString() with length zero, 10 which will be passed to jsSingleCharacterSubstring. 11 Add a slow case function to trap the error & return a safe null value, until the 12 exception is handled. 13 14 * runtime/JSString.cpp: 15 (JSC::JSString::getIndexSlowCase): 16 (JSC::JSString::getStringPropertyDescriptor): 17 * runtime/JSString.h: 18 (JSC::jsSingleCharacterSubstring): 19 (JSC::JSString::getIndex): 20 (JSC::jsSingleCharacterString): 21 (JSC::JSString::getStringPropertySlot): 22 1 23 2010-03-04 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 24 -
trunk/JavaScriptCore/runtime/JSString.cpp
r55833 r56021 105 105 } 106 106 107 JSString* JSString::getIndexSlowCase(ExecState* exec, unsigned i) 108 { 109 ASSERT(isRope()); 110 resolveRope(exec); 111 // Return a safe no-value result, this should never be used, since the excetion will be thrown. 112 if (exec->exception()) 113 return jsString(exec, ""); 114 ASSERT(!isRope()); 115 ASSERT(i < m_value.size()); 116 return jsSingleCharacterSubstring(exec, m_value, i); 117 } 118 107 119 JSValue JSString::toPrimitive(ExecState*, PreferredPrimitiveType) const 108 120 { … … 188 200 unsigned i = propertyName.toStrictUInt32(&isStrictUInt32); 189 201 if (isStrictUInt32 && i < m_length) { 190 descriptor.setDescriptor( jsSingleCharacterSubstring(exec, value(exec), i), DontDelete | ReadOnly);202 descriptor.setDescriptor(getIndex(exec, i), DontDelete | ReadOnly); 191 203 return true; 192 204 } -
trunk/JavaScriptCore/runtime/JSString.h
r55679 r56021 42 42 JSString* jsSingleCharacterString(JSGlobalData*, UChar); 43 43 JSString* jsSingleCharacterString(ExecState*, UChar); 44 JSString* jsSingleCharacterSubstring(JSGlobalData*, const UString&, unsigned offset);45 44 JSString* jsSingleCharacterSubstring(ExecState*, const UString&, unsigned offset); 46 45 JSString* jsSubstring(JSGlobalData*, const UString&, unsigned offset, unsigned length); … … 241 240 bool canGetIndex(unsigned i) { return i < m_length; } 242 241 JSString* getIndex(ExecState*, unsigned); 242 JSString* getIndexSlowCase(ExecState*, unsigned); 243 243 244 244 static PassRefPtr<Structure> createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(StringType, OverridesGetOwnPropertySlot | NeedsThisConversion), AnonymousSlotCount); } … … 366 366 } 367 367 368 inline JSString* jsSingleCharacterSubstring(JSGlobalData* globalData, const UString& s, unsigned offset) 369 { 368 inline JSString* jsSingleCharacterSubstring(ExecState* exec, const UString& s, unsigned offset) 369 { 370 JSGlobalData* globalData = &exec->globalData(); 370 371 ASSERT(offset < static_cast<unsigned>(s.size())); 371 372 UChar c = s.data()[offset]; … … 392 393 { 393 394 ASSERT(canGetIndex(i)); 394 return jsSingleCharacterSubstring(&exec->globalData(), value(exec), i); 395 if (isRope()) 396 return getIndexSlowCase(exec, i); 397 ASSERT(i < m_value.size()); 398 return jsSingleCharacterSubstring(exec, value(exec), i); 395 399 } 396 400 … … 446 450 inline JSString* jsString(ExecState* exec, const UString& s) { return jsString(&exec->globalData(), s); } 447 451 inline JSString* jsSingleCharacterString(ExecState* exec, UChar c) { return jsSingleCharacterString(&exec->globalData(), c); } 448 inline JSString* jsSingleCharacterSubstring(ExecState* exec, const UString& s, unsigned offset) { return jsSingleCharacterSubstring(&exec->globalData(), s, offset); }449 452 inline JSString* jsSubstring(ExecState* exec, const UString& s, unsigned offset, unsigned length) { return jsSubstring(&exec->globalData(), s, offset, length); } 450 453 inline JSString* jsNontrivialString(ExecState* exec, const UString& s) { return jsNontrivialString(&exec->globalData(), s); } … … 462 465 unsigned i = propertyName.toStrictUInt32(&isStrictUInt32); 463 466 if (isStrictUInt32 && i < m_length) { 464 slot.setValue( jsSingleCharacterSubstring(exec, value(exec), i));467 slot.setValue(getIndex(exec, i)); 465 468 return true; 466 469 } … … 472 475 { 473 476 if (propertyName < m_length) { 474 slot.setValue( jsSingleCharacterSubstring(exec, value(exec), propertyName));477 slot.setValue(getIndex(exec, propertyName)); 475 478 return true; 476 479 }
Note: See TracChangeset
for help on using the changeset viewer.