summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJani Taskinen <jani@php.net>2008-07-22 17:06:00 +0000
committerJani Taskinen <jani@php.net>2008-07-22 17:06:00 +0000
commitf7560881f6922ebf8285b10ceac98b546d7d19bc (patch)
treec4f79c95c36f1203128729a4946ca8512661b32c
parent9f26bea98fa2e7811728981f8597dd0562af8937 (diff)
downloadphp-git-f7560881f6922ebf8285b10ceac98b546d7d19bc.tar.gz
MFB:- Fixed bug #38680 (Added missing handling of basic types in json_decode)
# This was claimed to be in HEAD but wasn't..some commit reverted it or # someone didn't check for real..
-rw-r--r--ext/json/json.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/json/json.c b/ext/json/json.c
index 347f100dcd..9f86daa004 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -545,6 +545,8 @@ static PHP_FUNCTION(json_decode)
}
if (str_len > 1 && *str.s == '"' && str.s[str_len-1] == '"') {
RETURN_STRINGL(str.s+1, str_len-2, 1);
+ } else if (*str.s == '{' || *str.s == '[') { /* invalid JSON string */
+ RETURN_NULL();
} else {
RETURN_STRINGL(str.s, str_len, 1);
}
@@ -576,6 +578,8 @@ static PHP_FUNCTION(json_decode)
}
if (str_len > 1 && *str.u == 0x22 /*'"'*/ && str.u[str_len-1] == 0x22 /*'"'*/) {
RETURN_UNICODEL(str.u+1, str_len-2, 1);
+ } else if (*str.u == 0x7b /*'{'*/ || *str.u == 0x5b /*'['*/ ) { /* invalid JSON string */
+ RETURN_NULL();
} else {
RETURN_UNICODEL(str.u, str_len, 1);
}