53
53
#define PHP_JSON_INT_MAX_LENGTH (MAX_LENGTH_OF_LONG - 1 )
54
54
55
55
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)
57
57
{
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 ) ;
59
59
if (len) {
60
60
memcpy (s->pstr , s->str_start , len);
61
61
s->pstr += len;
62
62
}
63
63
}
64
64
65
- static int php_json_hex_to_int (char code)
65
+ static int php_json_hex_to_int (unsigned char code)
66
66
{
67
67
if (code >= ' 0' && code <= ' 9' ) {
68
68
return code - ' 0' ;
184
184
ZVAL_LONG(&s->value, ZEND_STRTOL((char *) s->token, NULL, 10));
185
185
return PHP_JSON_T_INT;
186
186
} 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) );
188
188
return PHP_JSON_T_STRING;
189
189
} else {
190
190
ZVAL_DOUBLE(&s->value, zend_strtod((char *) s->token, NULL));
258
258
}
259
259
<STR_P1>["] {
260
260
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) ;
262
262
if (len == 0) {
263
263
PHP_JSON_CONDITION_SET(JS);
264
264
ZVAL_EMPTY_STRING(&s->value);
@@ -299,24 +299,24 @@ std:
299
299
<STR_P2_UTF,STR_P2_BIN>UTF16_1 {
300
300
int utf16 = php_json_ucs2_to_int(s, 2);
301
301
PHP_JSON_SCANNER_COPY_UTF();
302
- *(s->pstr++) = (char) utf16;
302
+ *(s->pstr++) = (unsigned char) utf16;
303
303
s->str_start = s->cursor;
304
304
PHP_JSON_CONDITION_GOTO_STR_P2();
305
305
}
306
306
<STR_P2_UTF,STR_P2_BIN>UTF16_2 {
307
307
int utf16 = php_json_ucs2_to_int(s, 3);
308
308
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));
311
311
s->str_start = s->cursor;
312
312
PHP_JSON_CONDITION_GOTO_STR_P2();
313
313
}
314
314
<STR_P2_UTF,STR_P2_BIN>UTF16_3 {
315
315
int utf16 = php_json_ucs2_to_int(s, 4);
316
316
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));
320
320
s->str_start = s->cursor;
321
321
PHP_JSON_CONDITION_GOTO_STR_P2();
322
322
}
@@ -326,15 +326,15 @@ std:
326
326
utf16_lo = php_json_ucs2_to_int_ex(s, 4, 7);
327
327
utf32 = ((utf16_lo & 0x3FF) << 10) + (utf16_hi & 0x3FF) + 0x10000;
328
328
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));
333
333
s->str_start = s->cursor;
334
334
PHP_JSON_CONDITION_GOTO_STR_P2();
335
335
}
336
336
<STR_P2_UTF,STR_P2_BIN>ESCPREF {
337
- char esc;
337
+ unsigned char esc;
338
338
PHP_JSON_SCANNER_COPY_ESC();
339
339
switch (*s->cursor) {
340
340
case 'b':
374
374
if (s->utf8_invalid) {
375
375
PHP_JSON_SCANNER_COPY_ESC();
376
376
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));
380
380
}
381
381
s->str_start = s->cursor;
382
382
}
0 commit comments