Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions ext/standard/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,17 @@ PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
if (key_prefix && num_prefix) {
/* zend_string_concat4() */
size_t len = ZSTR_LEN(key_prefix) + num_prefix_len + index_int_as_str_len + strlen("%5D%5B");
new_prefix = zend_string_alloc(len, 0);

memcpy(ZSTR_VAL(new_prefix), ZSTR_VAL(key_prefix), ZSTR_LEN(key_prefix));
memcpy(ZSTR_VAL(new_prefix) + ZSTR_LEN(key_prefix), num_prefix, num_prefix_len);
memcpy(ZSTR_VAL(new_prefix) + ZSTR_LEN(key_prefix) + num_prefix_len, index_int_as_str, index_int_as_str_len);
memcpy(ZSTR_VAL(new_prefix) + ZSTR_LEN(key_prefix) + num_prefix_len +index_int_as_str_len, "%5D%5B", strlen("%5D%5B"));
ZSTR_VAL(new_prefix)[len] = '\0';
zend_string *tmp = zend_string_concat3(
ZSTR_VAL(key_prefix), ZSTR_LEN(key_prefix),
num_prefix, num_prefix_len,
index_int_as_str, index_int_as_str_len
);

new_prefix = zend_string_concat2(
ZSTR_VAL(tmp), ZSTR_LEN(tmp),
"%5D%5B", sizeof("%5D%5B") - 1
);
zend_string_release(tmp);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now instead of one unique allocation we have two. not sure we gain anything meaningful here.

} else if (key_prefix) {
new_prefix = zend_string_concat3(ZSTR_VAL(key_prefix), ZSTR_LEN(key_prefix), index_int_as_str, index_int_as_str_len, "%5D%5B", strlen("%5D%5B"));
} else if (num_prefix) {
Expand Down
Loading