JSONParse should not crash with null Strings
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Oct 2016 22:51:59 +0000 (22:51 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Oct 2016 22:51:59 +0000 (22:51 +0000)
commit08114bbb15cbb30248981cdf86a4e5169e24bbf7
tree8e935dbfc016593894fdab974d54833a6c6ec115
parent6cf1417bc1ed312795439b546d26736ca6941a98
JSONParse should not crash with null Strings
https://bugs.webkit.org/show_bug.cgi?id=163918
<rdar://problem/28834095>

Reviewed by Michael Saboff.

When JSONParse is called with a null String, it calls String::is8bit, which dereferences a null pointer.
This is happening with new work in the Fetch API, but callers of JSONParse should not have to check
if the String is null.

* API/tests/JSONParseTest.cpp: Added.
(testJSONParse):
* API/tests/JSONParseTest.h: Added.
* API/tests/testapi.c:
(main):
Test parsing null Strings.  They should have the same result as parsing empty Strings.
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/JSONObject.cpp:
(JSC::JSONParse):
Check for null Strings.
* shell/PlatformWin.cmake:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207785 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/API/tests/JSONParseTest.cpp [new file with mode: 0644]
Source/JavaScriptCore/API/tests/JSONParseTest.h [new file with mode: 0644]
Source/JavaScriptCore/API/tests/testapi.c
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/runtime/JSONObject.cpp
Source/JavaScriptCore/shell/PlatformWin.cmake