diff --git a/ext/json/json_scanner.re b/ext/json/json_scanner.re index be62875a00e0..fbbc6883b854 100644 --- a/ext/json/json_scanner.re +++ b/ext/json/json_scanner.re @@ -295,7 +295,7 @@ std: ANY { if (s->options & (PHP_JSON_INVALID_UTF8_IGNORE | PHP_JSON_INVALID_UTF8_SUBSTITUTE)) { if (s->options & PHP_JSON_INVALID_UTF8_SUBSTITUTE) { - if (s->utf8_invalid_count > INT_MAX - 2) { + if (s->utf8_invalid_count > PTRDIFF_MAX - 2) { s->errcode = PHP_JSON_ERROR_UTF8; return PHP_JSON_T_ERROR; } diff --git a/ext/json/php_json_scanner.h b/ext/json/php_json_scanner.h index f432f66b6d78..ff603fad26e7 100644 --- a/ext/json/php_json_scanner.h +++ b/ext/json/php_json_scanner.h @@ -31,12 +31,12 @@ typedef struct _php_json_scanner { php_json_ctype *line_start; /* start position of the current line */ uint64_t line; /* current line number (1-based) */ zval value; /* value */ - int str_esc; /* number of extra characters for escaping */ + ptrdiff_t str_esc; /* number of extra characters for escaping */ int state; /* condition state */ int options; /* options */ php_json_error_code errcode; /* error type if there is an error */ int utf8_invalid; /* whether utf8 is invalid */ - int utf8_invalid_count; /* number of extra character for invalid utf8 */ + ptrdiff_t utf8_invalid_count; /* number of extra character for invalid utf8 */ } php_json_scanner; void php_json_scanner_init(php_json_scanner *scanner, const char *str, size_t str_len, int options);