diff options
author | Scott MacVicar <scottmac@php.net> | 2009-07-27 03:43:38 +0000 |
---|---|---|
committer | Scott MacVicar <scottmac@php.net> | 2009-07-27 03:43:38 +0000 |
commit | 87dbefa03b02c7ec6e79654a04fe3b8b285b0be7 (patch) | |
tree | 3455290d44a451404e7d9347f3b320274b37aaa6 /ext/json/json.c | |
parent | 837732acc52c5d4a308915d97d792fcf0cb6aa06 (diff) | |
download | php-git-87dbefa03b02c7ec6e79654a04fe3b8b285b0be7.tar.gz |
MFH: Add error constant when json_encode detects an invalid UTF-8 sequence.
Diffstat (limited to 'ext/json/json.c')
-rw-r--r-- | ext/json/json.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ext/json/json.c b/ext/json/json.c index 5077dac562..7c21d33c9f 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -301,6 +301,7 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR efree(utf16); } if (len < 0) { + JSON_G(error_code) = PHP_JSON_ERROR_UTF8; if (!PG(display_errors)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid UTF-8 sequence in argument"); } @@ -413,6 +414,7 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR PHP_JSON_API void php_json_encode(smart_str *buf, zval *val, int options TSRMLS_DC) /* {{{ */ { + JSON_G(error_code) = PHP_JSON_ERROR_NONE; switch (Z_TYPE_P(val)) { case IS_NULL: |