Bug 88109

Summary: WebFrame::_stringByEvaluatingJavaScriptFromString methods don't handle nil string
Product: WebKit Reporter: Michael Saboff <msaboff>
Component: WebKit Misc.Assignee: Michael Saboff <msaboff>
Severity: Normal CC: thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Description Flags
ggaren: review-
Patch with fix ggaren: review+

Description Michael Saboff 2012-06-01 10:47:25 PDT
The various flavors of WebFrame::_stringByEvaluatingJavaScriptFromString don't properly handle nil string.  Instead such nil strings are passed down to the JavaScript engine where it may be a crash.

An if (!string) return @"": should be added as appropriate.
Comment 1 Michael Saboff 2012-06-01 11:52:01 PDT
Created attachment 145346 [details]
Comment 2 Simon Fraser (smfr) 2012-06-01 12:29:16 PDT
Comment on attachment 145346 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=145346&action=review

> Tools/TestWebKitAPI/Tests/mac/StringByEvaluatingJavaScriptFromString.mm:60
> +    EXPECT_EQ(nil, result);

Don't you expect an empty string, not a nil string?
Comment 3 Geoffrey Garen 2012-06-01 12:37:24 PDT
Comment on attachment 145346 [details]

Expectation should be empty string. Does nil pass?
Comment 4 Michael Saboff 2012-06-01 13:34:11 PDT
Created attachment 145369 [details]
Patch with fix

(In reply to comment #3)
> (From update of attachment 145346 [details])
> Expectation should be empty string. Does nil pass?

I was thinking about this as I was out at lunch, realizing that the test was wrong.  The test was "passing", but shouldn't.  I was assuming that run-test-webkit-api built the tests before running.  Therefore I wasn't testing the new code.  Built and tested this patch.  It works as expected.
Comment 5 Geoffrey Garen 2012-06-01 14:14:24 PDT
Comment on attachment 145369 [details]
Patch with fix

Comment 6 Michael Saboff 2012-06-01 14:26:29 PDT
Committed r119280: <http://trac.webkit.org/changeset/119280>
Comment 7 Radar WebKit Bug Importer 2012-06-07 17:07:16 PDT