Bug 20313

Summary: Add null check in String::fromUTF8()
Product: WebKit Reporter: Alp Toker <alp>
Component: TextAssignee: Nobody <webkit-unassigned>
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 17432    
Description Flags
Add null checks eric: review+

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)
    m_impl = StringImpl::create(str);

String::String(const char* str, unsigned length)
    if (!str)
    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