From 5484ebcc49a4cf6d598bef44b4e4e4c8f6cfcc6e Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Fri, 2 Jan 2026 09:03:17 -0800 Subject: [PATCH] streams/memory: Ensure internal string is NUL terminated (#20812) 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 785109db658..2f411ff8e8c 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; } }