Ignore:
Timestamp:
Feb 8, 2010, 3:43:26 PM (15 years ago)
Author:
[email protected]
Message:

Make makeString CRASH if we fail to allocate a string.

Reviewed by Geoff Garen.

(tryMakeString or jsMakeNontrivialString can be used where we
expect allocation may fail and want to handle the error).

  • runtime/JSStringBuilder.h:

(JSC::jsMakeNontrivialString):

  • runtime/UString.h:

(JSC::tryMakeString):
(JSC::makeString):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSStringBuilder.h

    r54403 r54518  
    4747inline JSValue jsMakeNontrivialString(ExecState* exec, StringType1 string1, StringType2 string2)
    4848{
    49     UString result = makeString(string1, string2);
    50     if (result.isNull())
     49    PassRefPtr<UStringImpl> result = tryMakeString(string1, string2);
     50    if (!result)
    5151        return throwOutOfMemoryError(exec);
    5252    return jsNontrivialString(exec, result);
     
    5656inline JSValue jsMakeNontrivialString(ExecState* exec, StringType1 string1, StringType2 string2, StringType3 string3)
    5757{
    58     UString result = makeString(string1, string2, string3);
    59     if (result.isNull())
     58    PassRefPtr<UStringImpl> result = tryMakeString(string1, string2, string3);
     59    if (!result)
    6060        return throwOutOfMemoryError(exec);
    6161    return jsNontrivialString(exec, result);
     
    6565inline JSValue jsMakeNontrivialString(ExecState* exec, StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4)
    6666{
    67     UString result = makeString(string1, string2, string3, string4);
    68     if (result.isNull())
     67    PassRefPtr<UStringImpl> result = tryMakeString(string1, string2, string3, string4);
     68    if (!result)
    6969        return throwOutOfMemoryError(exec);
    7070    return jsNontrivialString(exec, result);
     
    7474inline JSValue jsMakeNontrivialString(ExecState* exec, StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5)
    7575{
    76     UString result = makeString(string1, string2, string3, string4, string5);
    77     if (result.isNull())
     76    PassRefPtr<UStringImpl> result = tryMakeString(string1, string2, string3, string4, string5);
     77    if (!result)
    7878        return throwOutOfMemoryError(exec);
    7979    return jsNontrivialString(exec, result);
     
    8383inline JSValue jsMakeNontrivialString(ExecState* exec, StringType1 string1, StringType2 string2, StringType3 string3, StringType4 string4, StringType5 string5, StringType6 string6)
    8484{
    85     UString result = makeString(string1, string2, string3, string4, string5, string6);
    86     if (result.isNull())
     85    PassRefPtr<UStringImpl> result = tryMakeString(string1, string2, string3, string4, string5, string6);
     86    if (!result)
    8787        return throwOutOfMemoryError(exec);
    8888    return jsNontrivialString(exec, result);
Note: See TracChangeset for help on using the changeset viewer.