Commit 78f2d440900 for php.net
commit 78f2d4409005a2805b1caafe80c4ec15a456d0d7
Author: Weilin Du <108666168+LamentXU123@users.noreply.github.com>
Date: Sat Mar 28 23:35:34 2026 +0800
uri: Preinitialize `errors` array with the correct size in `fill_errors()` (#21560)
diff --git a/ext/uri/uri_parser_whatwg.c b/ext/uri/uri_parser_whatwg.c
index 055f130af7c..9d5e87fd4cf 100644
--- a/ext/uri/uri_parser_whatwg.c
+++ b/ext/uri/uri_parser_whatwg.c
@@ -62,12 +62,13 @@ static zend_always_inline void zval_long_or_null_to_lexbor_str(zval *value, lexb
*/
static const char *fill_errors(zval *errors)
{
- if (lexbor_parser.log == NULL || lexbor_plog_length(lexbor_parser.log) == 0) {
+ size_t log_len;
+ if (lexbor_parser.log == NULL || (log_len = lexbor_plog_length(lexbor_parser.log)) == 0) {
ZVAL_EMPTY_ARRAY(errors);
return NULL;
}
- array_init(errors);
+ array_init_size(errors, log_len);
const char *result = NULL;
lexbor_plog_entry_t *lxb_error;