mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix #80663: Recursive SplFixedArray::setSize() may cause double-free
This commit is contained in:
4
NEWS
4
NEWS
@@ -11,6 +11,10 @@ PHP NEWS
|
||||
ReflectionClass). (Nikita)
|
||||
. Fixed bug #81474 (Make ReflectionEnum and related class non-final). (Nikita)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #80663 (Recursive SplFixedArray::setSize() may cause double-free).
|
||||
(cmb, Nikita, Tyson Andre)
|
||||
|
||||
- XML:
|
||||
. Fixed bug #70962 (XML_OPTION_SKIP_WHITE strips embedded whitespace).
|
||||
(Aliaksandr Bystry, cmb)
|
||||
|
||||
@@ -156,10 +156,14 @@ static void spl_fixedarray_dtor_range(spl_fixedarray *array, zend_long from, zen
|
||||
*/
|
||||
static void spl_fixedarray_dtor(spl_fixedarray *array)
|
||||
{
|
||||
zend_long size = array->size;
|
||||
if (!spl_fixedarray_empty(array)) {
|
||||
spl_fixedarray_dtor_range(array, 0, size);
|
||||
efree(array->elements);
|
||||
zval *begin = array->elements, *end = array->elements + array->size;
|
||||
array->elements = NULL;
|
||||
array->size = 0;
|
||||
while (begin != end) {
|
||||
zval_ptr_dtor(--end);
|
||||
}
|
||||
efree(begin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
15
ext/spl/tests/bug80663.phpt
Normal file
15
ext/spl/tests/bug80663.phpt
Normal file
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Bug #80663 (Recursive SplFixedArray::setSize() may cause double-free)
|
||||
--FILE--
|
||||
<?php
|
||||
class InvalidDestructor {
|
||||
public function __destruct() {
|
||||
$GLOBALS['obj']->setSize(0);
|
||||
}
|
||||
}
|
||||
|
||||
$obj = new SplFixedArray(1000);
|
||||
$obj[0] = new InvalidDestructor();
|
||||
$obj->setSize(0);
|
||||
?>
|
||||
--EXPECT--
|
||||
Reference in New Issue
Block a user