Bug 88109 - WebFrame::_stringByEvaluatingJavaScriptFromString methods don't handle nil string
Summary: WebFrame::_stringByEvaluatingJavaScriptFromString methods don't handle nil st...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2012-06-01 10:47 PDT by Michael Saboff
Modified: 2012-06-07 17:07 PDT (History)
2 users (show)

See Also:


Attachments
Patch (3.40 KB, patch)
2012-06-01 11:52 PDT, Michael Saboff
ggaren: review-
Details | Formatted Diff | Diff
Patch with fix (3.41 KB, patch)
2012-06-01 13:34 PDT, Michael Saboff
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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]
Patch
Comment 2 Simon Fraser (smfr) 2012-06-01 12:29:16 PDT
Comment on attachment 145346 [details]
Patch

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]
Patch

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

r=me
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
<rdar://problem/11620927>