Skip to content

Commit 5b53f0f

Browse files
committed
Add an assertion about the reallocation
1 parent ec975f4 commit 5b53f0f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sapi/cli/php_cli_server.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,9 +1670,11 @@ static int php_cli_server_client_read_request_on_header_value(php_http_parser *p
16701670
client->current_header_value = zend_string_init(at, length, /* persistent */ true);
16711671
break;
16721672
case HEADER_VALUE: {
1673+
/* Assert that there is only one reference to the header value, as then zend_string_extends()
1674+
* will reallocate it such that we do not need to release the old value. */
1675+
ZEND_ASSERT(GC_REFCOUNT(client->current_header_value) == 1);
16731676
/* Previous element was part of header value, append content to it */
16741677
size_t old_length = ZSTR_LEN(client->current_header_value);
1675-
// TODO Release old value?
16761678
client->current_header_value = zend_string_extend(client->current_header_value, old_length + length, /* persistent */ true);
16771679
memcpy(ZSTR_VAL(client->current_header_value) + old_length, at, length);
16781680
// Null terminate

0 commit comments

Comments
 (0)