From: Jani Taskinen Date: Tue, 22 Jul 2008 17:06:00 +0000 (+0000) Subject: MFB:- Fixed bug #38680 (Added missing handling of basic types in json_decode) X-Git-Tag: BEFORE_HEAD_NS_CHANGE~1141 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f7560881f6922ebf8285b10ceac98b546d7d19bc;p=php 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.. --- 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); }