Bug 154540

Summary: JSString::value() should return the empty string when out of memory.
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: JavaScriptCoreAssignee: Mark Lam <mark.lam>
Status: ASSIGNED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
work in progress for archiving. Not done yet. none

Mark Lam
Reported 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.
Attachments
work in progress for archiving. Not done yet. (137.18 KB, patch)
2016-02-22 09:45 PST, Mark Lam
no flags
Radar WebKit Bug Importer
Comment 1 2016-02-22 09:40:49 PST
Mark Lam
Comment 2 2016-02-22 09:45:15 PST
Created attachment 271927 [details] work in progress for archiving. Not done yet.
Note You need to log in before you can comment on or make changes to this bug.