From f537fa7cc1f7296ad91898406619fbc53fe69450 Mon Sep 17 00:00:00 2001 From: Owen Yamauchi Date: Fri, 17 May 2013 10:37:45 -0700 Subject: [PATCH] JSON parser: fix empty dictionaries inside of dictionaries I broke this with my change to stop boxing everything. It was dropping empty dictionaries inside dictionaries, because the "}" of empty dictionaries is a different parser action from the "}" of nonempty dictionaries, and I'd neglected to update it. (The fact that no tests caught this before is a little unsettling.) --- hphp/runtime/ext/JSON_parser.cpp | 2 ++ hphp/test/slow/json/emptydict.php | 11 +++++++++++ hphp/test/slow/json/emptydict.php.expect | 7 +++++++ 3 files changed, 20 insertions(+) create mode 100644 hphp/test/slow/json/emptydict.php create mode 100644 hphp/test/slow/json/emptydict.php.expect diff --git a/hphp/runtime/ext/JSON_parser.cpp b/hphp/runtime/ext/JSON_parser.cpp index 9970d4da3..18a18cbcb 100644 --- a/hphp/runtime/ext/JSON_parser.cpp +++ b/hphp/runtime/ext/JSON_parser.cpp @@ -551,6 +551,8 @@ bool JSON_parser(Variant &z, const char *p, int length, bool assoc/**/, empty } */ case -9: + attach_zval(the_json, JSON(the_kstack)[JSON(the_top)], assoc); + if (!pop(the_json, MODE_KEY)) { return false; } diff --git a/hphp/test/slow/json/emptydict.php b/hphp/test/slow/json/emptydict.php new file mode 100644 index 000000000..44282e271 --- /dev/null +++ b/hphp/test/slow/json/emptydict.php @@ -0,0 +1,11 @@ + + array(0) { + } + ["spaceId"]=> + int(3) +}