From 914804cabc6f6b59fd7ea8e0a7d7ea4771332450 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Wed, 31 Dec 2025 00:38:07 +0100 Subject: [PATCH] streams/memory: Ensure internal string is NUL terminated zend_string_truncate() doesn't put a NUL byte. --- main/streams/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/streams/memory.c b/main/streams/memory.c index 785109db6582..2f411ff8e8c9 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -247,8 +247,8 @@ static int php_stream_memory_set_option(php_stream *stream, int option, int valu size_t old_size = ZSTR_LEN(ms->data); ms->data = zend_string_realloc(ms->data, newsize, 0); memset(ZSTR_VAL(ms->data) + old_size, 0, newsize - old_size); - ZSTR_VAL(ms->data)[ZSTR_LEN(ms->data)] = '\0'; } + ZSTR_VAL(ms->data)[ZSTR_LEN(ms->data)] = '\0'; return PHP_STREAM_OPTION_RETURN_OK; } }