Fix a json_decode crash when depth==0
commitdabd48caf74995e605f1700344f1ff4a5d83441d
authorMark Williams <mwilliams@fb.com>
Thu, 20 Feb 2020 23:41:33 +0000 (20 15:41 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 20 Feb 2020 23:43:49 +0000 (20 15:43 -0800)
treeb936fba090fc906eff1391eb614c12af526ede50
parentdb8bdb91990462436dc00d7c51df32d6b1f3fbd9
Fix a json_decode crash when depth==0

Summary:
Setting depth=0 is an error, and should result in NULL, but we weren't
checking for it, so in the case of a single, top-level string, we
would reading the -1th element of the stack.

Differential Revision: D19609959

fbshipit-source-id: 04ca1e0965e04b44df2d5c806a73c3da99ff66fb
hphp/runtime/ext/json/JSON_parser.cpp
hphp/test/slow/ext_json/decode_crash.php [new file with mode: 0644]
hphp/test/slow/ext_json/decode_crash.php.expect [new file with mode: 0644]