Bug 20313 - Add null check in String::fromUTF8()
Summary: Add null check in String::fromUTF8()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 17432
  Show dependency treegraph
 
Reported: 2008-08-06 21:48 PDT by Alp Toker
Modified: 2008-08-07 05:10 PDT (History)
0 users

See Also:


Attachments
Add null checks (1.27 KB, patch)
2008-08-06 21:51 PDT, Alp Toker
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alp Toker 2008-08-06 21:48:03 PDT
String::fromUTF8() crashes when passed a null pointer. This behaviour is inconsistent with the other constructors, which return a null String() in this case:

String::String(const char* str)
{
    if (!str)
        return;
    m_impl = StringImpl::create(str);
}

String::String(const char* str, unsigned length)
{
    if (!str)
        return;
    m_impl = StringImpl::create(str, length);
}

Fix attached. This allows us to simplify (or avoid) null checking logic wherever String::fromUTF8() is used.
Comment 1 Alp Toker 2008-08-06 21:51:25 PDT
Created attachment 22692 [details]
Add null checks
Comment 2 Eric Seidel (no email) 2008-08-06 22:43:12 PDT
Comment on attachment 22692 [details]
Add null checks

Looks fine.
Comment 3 Jan Alonzo 2008-08-07 05:10:28 PDT
landed in r35623