Skip to content

Commit 5484ebc

Browse files
authored
streams/memory: Ensure internal string is NUL terminated (#20812)
zend_string_truncate() doesn't put a NUL byte.
1 parent 30ed813 commit 5484ebc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main/streams/memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ static int php_stream_memory_set_option(php_stream *stream, int option, int valu
247247
size_t old_size = ZSTR_LEN(ms->data);
248248
ms->data = zend_string_realloc(ms->data, newsize, 0);
249249
memset(ZSTR_VAL(ms->data) + old_size, 0, newsize - old_size);
250-
ZSTR_VAL(ms->data)[ZSTR_LEN(ms->data)] = '\0';
251250
}
251+
ZSTR_VAL(ms->data)[ZSTR_LEN(ms->data)] = '\0';
252252
return PHP_STREAM_OPTION_RETURN_OK;
253253
}
254254
}

0 commit comments

Comments
 (0)