summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--ext/json/json.c2
-rw-r--r--ext/json/tests/002.phpt2
-rw-r--r--ext/json/tests/bug41034.phptbin0 -> 297 bytes
4 files changed, 4 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 67da13e199..6a44880d83 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ PHP NEWS
- Fixed bug #41063 (chdir doesn't like root paths). (Dmitry)
- Fixed bug #41061 ("visibility error" in ReflectionFunction::export()).
(Johannes)
+- Fixed bug #41034 (json_encode() ignores null byte started keys in arrays).
+ (Ilia)
- Fixed bug #40861 (strtotime() doesn't handle double negative relative time
units correctly). (Derick)
diff --git a/ext/json/json.c b/ext/json/json.c
index 1bfe3e0743..809d005c57 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -177,7 +177,7 @@ static void json_encode_array(smart_str *buf, zval **val TSRMLS_DC) {
json_encode_r(buf, *data TSRMLS_CC);
} else if (r == 1) {
if (i == HASH_KEY_IS_STRING) {
- if (key[0] == '\0') {
+ if (key[0] == '\0' && Z_TYPE_PP(val) == IS_OBJECT) {
/* Skip protected and private members. */
continue;
}
diff --git a/ext/json/tests/002.phpt b/ext/json/tests/002.phpt
index 5bc29bc5b9..87f57421f3 100644
--- a/ext/json/tests/002.phpt
+++ b/ext/json/tests/002.phpt
@@ -21,7 +21,7 @@ echo "Done\n";
string(2) """"
string(4) "null"
string(4) "true"
-string(2) "{}"
+string(7) "{"":""}"
string(5) "[[1]]"
string(1) "1"
string(38) ""\u0440\u0443\u0441\u0441\u0438\u0448""
diff --git a/ext/json/tests/bug41034.phpt b/ext/json/tests/bug41034.phpt
new file mode 100644
index 0000000000..7a7e5f758a
--- /dev/null
+++ b/ext/json/tests/bug41034.phpt
Binary files differ