Skip to content

Commit 78f2d44

Browse files
authored
uri: Preinitialize errors array with the correct size in fill_errors() (php#21560)
1 parent 465ecaa commit 78f2d44

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/uri/uri_parser_whatwg.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ static zend_always_inline void zval_long_or_null_to_lexbor_str(zval *value, lexb
6262
*/
6363
static const char *fill_errors(zval *errors)
6464
{
65-
if (lexbor_parser.log == NULL || lexbor_plog_length(lexbor_parser.log) == 0) {
65+
size_t log_len;
66+
if (lexbor_parser.log == NULL || (log_len = lexbor_plog_length(lexbor_parser.log)) == 0) {
6667
ZVAL_EMPTY_ARRAY(errors);
6768
return NULL;
6869
}
6970

70-
array_init(errors);
71+
array_init_size(errors, log_len);
7172
const char *result = NULL;
7273

7374
lexbor_plog_entry_t *lxb_error;

0 commit comments

Comments
 (0)