5353#define PHP_JSON_INT_MAX_LENGTH (MAX_LENGTH_OF_LONG - 1 )
5454
5555
56- static void php_json_scanner_copy_string (php_json_scanner *s, int esc_size)
56+ static void php_json_scanner_copy_string (php_json_scanner *s, size_t esc_size)
5757{
58- size_t len = s->cursor - s->str_start - esc_size - 1 ;
58+ size_t len = ( size_t )( s->cursor - s->str_start - esc_size - 1 ) ;
5959 if (len) {
6060 memcpy (s->pstr , s->str_start , len);
6161 s->pstr += len;
6262 }
6363}
6464
65- static int php_json_hex_to_int (char code)
65+ static int php_json_hex_to_int (unsigned char code)
6666{
6767 if (code >= ' 0' && code <= ' 9' ) {
6868 return code - ' 0' ;
184184 ZVAL_LONG(&s->value, ZEND_STRTOL((char *) s->token, NULL, 10));
185185 return PHP_JSON_T_INT;
186186 } else if (s->options & PHP_JSON_BIGINT_AS_STRING) {
187- ZVAL_STRINGL(&s->value, (char *) s->token, s->cursor - s->token);
187+ ZVAL_STRINGL(&s->value, (char *) s->token, (size_t)( s->cursor - s->token) );
188188 return PHP_JSON_T_STRING;
189189 } else {
190190 ZVAL_DOUBLE(&s->value, zend_strtod((char *) s->token, NULL));
258258 }
259259 <STR_P1>["] {
260260 zend_string *str;
261- size_t len = s->cursor - s->str_start - s->str_esc - 1 + s->utf8_invalid_count;
261+ size_t len = (size_t)( s->cursor - s->str_start - s->str_esc - 1 + s->utf8_invalid_count) ;
262262 if (len == 0) {
263263 PHP_JSON_CONDITION_SET(JS);
264264 ZVAL_EMPTY_STRING(&s->value);
@@ -299,24 +299,24 @@ std:
299299 <STR_P2_UTF,STR_P2_BIN>UTF16_1 {
300300 int utf16 = php_json_ucs2_to_int(s, 2);
301301 PHP_JSON_SCANNER_COPY_UTF();
302- *(s->pstr++) = (char) utf16;
302+ *(s->pstr++) = (unsigned char) utf16;
303303 s->str_start = s->cursor;
304304 PHP_JSON_CONDITION_GOTO_STR_P2();
305305 }
306306 <STR_P2_UTF,STR_P2_BIN>UTF16_2 {
307307 int utf16 = php_json_ucs2_to_int(s, 3);
308308 PHP_JSON_SCANNER_COPY_UTF();
309- *(s->pstr++) = (char) (0xc0 | (utf16 >> 6));
310- *(s->pstr++) = (char) (0x80 | (utf16 & 0x3f));
309+ *(s->pstr++) = (unsigned char) (0xc0 | (utf16 >> 6));
310+ *(s->pstr++) = (unsigned char) (0x80 | (utf16 & 0x3f));
311311 s->str_start = s->cursor;
312312 PHP_JSON_CONDITION_GOTO_STR_P2();
313313 }
314314 <STR_P2_UTF,STR_P2_BIN>UTF16_3 {
315315 int utf16 = php_json_ucs2_to_int(s, 4);
316316 PHP_JSON_SCANNER_COPY_UTF();
317- *(s->pstr++) = (char) (0xe0 | (utf16 >> 12));
318- *(s->pstr++) = (char) (0x80 | ((utf16 >> 6) & 0x3f));
319- *(s->pstr++) = (char) (0x80 | (utf16 & 0x3f));
317+ *(s->pstr++) = (unsigned char) (0xe0 | (utf16 >> 12));
318+ *(s->pstr++) = (unsigned char) (0x80 | ((utf16 >> 6) & 0x3f));
319+ *(s->pstr++) = (unsigned char) (0x80 | (utf16 & 0x3f));
320320 s->str_start = s->cursor;
321321 PHP_JSON_CONDITION_GOTO_STR_P2();
322322 }
@@ -326,15 +326,15 @@ std:
326326 utf16_lo = php_json_ucs2_to_int_ex(s, 4, 7);
327327 utf32 = ((utf16_lo & 0x3FF) << 10) + (utf16_hi & 0x3FF) + 0x10000;
328328 PHP_JSON_SCANNER_COPY_UTF_SP();
329- *(s->pstr++) = (char) (0xf0 | (utf32 >> 18));
330- *(s->pstr++) = (char) (0x80 | ((utf32 >> 12) & 0x3f));
331- *(s->pstr++) = (char) (0x80 | ((utf32 >> 6) & 0x3f));
332- *(s->pstr++) = (char) (0x80 | (utf32 & 0x3f));
329+ *(s->pstr++) = (unsigned char) (0xf0 | (utf32 >> 18));
330+ *(s->pstr++) = (unsigned char) (0x80 | ((utf32 >> 12) & 0x3f));
331+ *(s->pstr++) = (unsigned char) (0x80 | ((utf32 >> 6) & 0x3f));
332+ *(s->pstr++) = (unsigned char) (0x80 | (utf32 & 0x3f));
333333 s->str_start = s->cursor;
334334 PHP_JSON_CONDITION_GOTO_STR_P2();
335335 }
336336 <STR_P2_UTF,STR_P2_BIN>ESCPREF {
337- char esc;
337+ unsigned char esc;
338338 PHP_JSON_SCANNER_COPY_ESC();
339339 switch (*s->cursor) {
340340 case 'b':
374374 if (s->utf8_invalid) {
375375 PHP_JSON_SCANNER_COPY_ESC();
376376 if (s->options & PHP_JSON_INVALID_UTF8_SUBSTITUTE) {
377- *(s->pstr++) = (char) (0xe0 | (0xfffd >> 12));
378- *(s->pstr++) = (char) (0x80 | ((0xfffd >> 6) & 0x3f));
379- *(s->pstr++) = (char) (0x80 | (0xfffd & 0x3f));
377+ *(s->pstr++) = (unsigned char) (0xe0 | (0xfffd >> 12));
378+ *(s->pstr++) = (unsigned char) (0x80 | ((0xfffd >> 6) & 0x3f));
379+ *(s->pstr++) = (unsigned char) (0x80 | (0xfffd & 0x3f));
380380 }
381381 s->str_start = s->cursor;
382382 }
0 commit comments