mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-14290: Member access within null pointer in extension spl
This commit is contained in:
3
NEWS
3
NEWS
@@ -2,6 +2,9 @@ PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? ????, PHP 8.3.9
|
||||
|
||||
- SPL:
|
||||
. Fixed bug GH-14290 (Member access within null pointer in extension spl).
|
||||
(nielsdos)
|
||||
|
||||
23 May 2024, PHP 8.3.8RC1
|
||||
|
||||
|
||||
@@ -1898,12 +1898,17 @@ PHP_METHOD(RegexIterator, accept)
|
||||
zval *replacement = zend_read_property(intern->std.ce, Z_OBJ_P(ZEND_THIS), "replacement", sizeof("replacement")-1, 1, &rv);
|
||||
zend_string *replacement_str = zval_try_get_string(replacement);
|
||||
|
||||
if (UNEXPECTED(!replacement_str)) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
/* Property type is ?string, so this should always succeed. */
|
||||
ZEND_ASSERT(replacement_str != NULL);
|
||||
|
||||
result = php_pcre_replace_impl(intern->u.regex.pce, subject, ZSTR_VAL(subject), ZSTR_LEN(subject), replacement_str, -1, &count);
|
||||
|
||||
if (UNEXPECTED(!result)) {
|
||||
zend_string_release(replacement_str);
|
||||
zend_string_release_ex(subject, false);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (intern->u.regex.flags & REGIT_USE_KEY) {
|
||||
zval_ptr_dtor(&intern->current.key);
|
||||
ZVAL_STR(&intern->current.key, result);
|
||||
@@ -1920,7 +1925,7 @@ PHP_METHOD(RegexIterator, accept)
|
||||
if (intern->u.regex.flags & REGIT_INVERTED) {
|
||||
RETVAL_BOOL(Z_TYPE_P(return_value) != IS_TRUE);
|
||||
}
|
||||
zend_string_release_ex(subject, 0);
|
||||
zend_string_release_ex(subject, false);
|
||||
} /* }}} */
|
||||
|
||||
/* {{{ Returns current regular expression */
|
||||
|
||||
16
ext/spl/tests/gh14290.phpt
Normal file
16
ext/spl/tests/gh14290.phpt
Normal file
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
GH-14290 (Member access within null pointer in extension spl)
|
||||
--INI--
|
||||
pcre.backtrack_limit=2
|
||||
pcre.jit=0
|
||||
--FILE--
|
||||
<?php
|
||||
$h = new ArrayIterator(['test' => 'test1']);
|
||||
$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE);
|
||||
foreach ($i as $name => $value) {
|
||||
var_dump($name, $value);
|
||||
}
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Done
|
||||
Reference in New Issue
Block a user