1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix refcounting on zend_empty_array in ext-uri (GH-19908)

Fixes GH-19892
This commit is contained in:
Ilija Tovilo
2025-09-21 21:56:04 +02:00
committed by GitHub
parent 9fe6fb2566
commit 5897071ab6
4 changed files with 15 additions and 1 deletions

1
NEWS
View File

@@ -58,6 +58,7 @@ PHP NEWS
. Add new Uri\UriError exception that is thrown for internal error
conditions. (timwolla)
. Further clean up the internal API. (timwolla)
. Fixed bug GH-19892 (Refcounting on zend_empty_array). (ilutov, timwolla)
- Windows:
. Fix GH-19722 (_get_osfhandle asserts in debug mode when given a socket).

View File

@@ -1364,6 +1364,7 @@ ZEND_API zend_result zend_try_assign_typed_ref_zval_ex(zend_reference *ref, zval
#define ZEND_TRY_ASSIGN_REF_ARR(zv, arr) do { \
ZEND_ASSERT(Z_ISREF_P(zv)); \
ZEND_ASSERT(!(GC_FLAGS(arr) & GC_IMMUTABLE)); \
_ZEND_TRY_ASSIGN_ARR(zv, arr, 1); \
} while (0)

View File

@@ -308,7 +308,7 @@ static zend_result pass_errors_by_ref_and_free(zval *errors_zv, zval *errors)
return SUCCESS;
}
ZEND_TRY_ASSIGN_REF_ARR(errors_zv, Z_ARRVAL_P(errors));
ZEND_TRY_ASSIGN_REF_TMP(errors_zv, errors);
if (EG(exception)) {
return FAILURE;
}

View File

@@ -0,0 +1,12 @@
--TEST--
GH-19892: Successful \Uri\WhatWg\Url::parse() with empty errors array
--FILE--
<?php
\Uri\WhatWg\Url::parse('https://example.com', errors: $errors);
var_dump($errors);
?>
--EXPECT--
array(0) {
}