Skip to content

Commit c51ea47

Browse files
committed
Change string buffer handling in json scanner
1 parent 098097d commit c51ea47

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/json/json_scanner.re

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,16 @@ std:
234234
return PHP_JSON_T_ERROR;
235235
}
236236
<STR_P1>["] {
237-
char *str;
237+
zend_string *str;
238238
size_t len = s->cursor - s->str_start - s->str_esc - 1;
239239
if (len == 0) {
240240
PHP_JSON_CONDITION_SET(JS);
241241
ZVAL_EMPTY_STRING(&s->value);
242242
return PHP_JSON_T_ESTRING;
243243
}
244-
str = emalloc(len + 1);
245-
str[len] = 0;
246-
ZVAL_STRINGL(&s->value, str, len);
244+
str = zend_string_alloc(len, 0);
245+
str->val[len] = '\0';
246+
ZVAL_STR(&s->value, str);
247247
if (s->str_esc) {
248248
s->pstr = (php_json_ctype *) Z_STRVAL(s->value);
249249
s->cursor = s->str_start;

0 commit comments

Comments
 (0)