Commit 5484ebcc49a for php.net

commit 5484ebcc49a4cf6d598bef44b4e4e4c8f6cfcc6e
Author: Niels Dossche <7771979+ndossche@users.noreply.github.com>
Date:   Fri Jan 2 09:03:17 2026 -0800

    streams/memory: Ensure internal string is NUL terminated (#20812)

    zend_string_truncate() doesn't put a NUL byte.

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;
 			}
 	}