Ignore:
Timestamp:
Nov 17, 2010, 8:36:04 AM (15 years ago)
Author:
[email protected]
Message:

<http://webkit.org/b/49634> Make overflow guards in WTF::String::utf8 explicit

Reviewed by Darin Adler.

Add an explicit overflow check prior to allocating our buffer,
rather than implicitly relying on the guard in convertUTF16ToUTF8.

  • wtf/text/WTFString.cpp:

(WTF::String::utf8):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/text/WTFString.cpp

    r72114 r72209  
    3737
    3838using namespace Unicode;
     39using namespace std;
    3940
    4041// Construct a string with UTF-16 data.
     
    697698    //    have a good chance of being able to write the string into the
    698699    //    buffer without reallocing (say, 1.5 x length).
     700    if (length > numeric_limits<unsigned>::max() / 3)
     701        return CString();
    699702    Vector<char, 1024> bufferVector(length * 3);
    700703
Note: See TracChangeset for help on using the changeset viewer.