@@ -184,13 +184,17 @@ PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
184184 if (key_prefix && num_prefix ) {
185185 /* zend_string_concat4() */
186186 size_t len = ZSTR_LEN (key_prefix ) + num_prefix_len + index_int_as_str_len + strlen ("%5D%5B" );
187- new_prefix = zend_string_alloc (len , 0 );
188-
189- memcpy (ZSTR_VAL (new_prefix ), ZSTR_VAL (key_prefix ), ZSTR_LEN (key_prefix ));
190- memcpy (ZSTR_VAL (new_prefix ) + ZSTR_LEN (key_prefix ), num_prefix , num_prefix_len );
191- memcpy (ZSTR_VAL (new_prefix ) + ZSTR_LEN (key_prefix ) + num_prefix_len , index_int_as_str , index_int_as_str_len );
192- memcpy (ZSTR_VAL (new_prefix ) + ZSTR_LEN (key_prefix ) + num_prefix_len + index_int_as_str_len , "%5D%5B" , strlen ("%5D%5B" ));
193- ZSTR_VAL (new_prefix )[len ] = '\0' ;
187+ zend_string * tmp = zend_string_concat3 (
188+ ZSTR_VAL (key_prefix ), ZSTR_LEN (key_prefix ),
189+ num_prefix , num_prefix_len ,
190+ index_int_as_str , index_int_as_str_len
191+ );
192+
193+ new_prefix = zend_string_concat2 (
194+ ZSTR_VAL (tmp ), ZSTR_LEN (tmp ),
195+ "%5D%5B" , sizeof ("%5D%5B" ) - 1
196+ );
197+ zend_string_release (tmp );
194198 } else if (key_prefix ) {
195199 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" ));
196200 } else if (num_prefix ) {
0 commit comments