Bug 154540 - JSString::value() should return the empty string when out of memory.
Summary: JSString::value() should return the empty string when out of memory.
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-02-22 09:39 PST by Mark Lam
Modified: 2016-02-22 09:45 PST (History)
1 user (show)

See Also:


Attachments
work in progress for archiving. Not done yet. (137.18 KB, patch)
2016-02-22 09:45 PST, Mark Lam
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2016-02-22 09:39:49 PST
The current implementation of JString::value() returns a null string when it fails to resolve its rope in the event of an OutOfMemory error.  This can result in null pointer dereferences if callers of the function uses the returned string without checking first for an exception or if the string is null.  We can make the code more resilient against such null pointer dereferences by having JSString::value() return an empty string instead of a null string.  Callers that previously checked for a null string (as an indication of the OutOfMemory error) can now check for an exception instead.

This task will do an audit of all uses of JSString::value() in the project and:
1. make sure that the uses are not dependent on the return string being null, and hence is ok with it returning an empty string.
2. add exception checks where needed.
Comment 1 Radar WebKit Bug Importer 2016-02-22 09:40:49 PST
<rdar://problem/24770483>
Comment 2 Mark Lam 2016-02-22 09:45:15 PST
Created attachment 271927 [details]
work in progress for archiving.  Not done yet.