From 847497f842ebcd05ad56d12eca04e95acbe4c534 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 6 Feb 2025 21:44:51 +0100 Subject: [PATCH] tweak --- ext/json/json_encoder.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c index e9e0a6a9aa645..75c4f6f8e0aa4 100644 --- a/ext/json/json_encoder.c +++ b/ext/json/json_encoder.c @@ -379,7 +379,7 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options, /* }}} */ /* Specialization of smart_str_appendl() to avoid performance loss due to code bloat */ -static void php_json_append(smart_str *dest, const char *src, size_t len) +static zend_always_inline void php_json_append(smart_str *dest, const char *src, size_t len) { /* smart_str has a minimum size of the input length, * this avoids generating initial allocation code */ @@ -688,8 +688,8 @@ zend_result php_json_escape_string( const char *cur = s + pos; pos = 0; us = php_next_utf8_char((unsigned char *)cur, len, &pos, &status); + len -= pos; pos += pos_old; - len -= pos - pos_old; /* check whether UTF8 character is correct */ if (UNEXPECTED(!us)) { @@ -807,6 +807,7 @@ zend_result php_json_escape_string( php_json_append(buf, s, pos); } + ZEND_ASSERT(buf->s); smart_str_appendc(buf, '"'); return SUCCESS;