Merge branch 'PHP-7.3' into PHP-7.4

* PHP-7.3:
  Fixed bug #79792
This commit is contained in:
Nikita Popov 2020-07-07 11:59:20 +02:00
commit 48a247178e
3 changed files with 20 additions and 2 deletions

2
NEWS
View File

@ -17,6 +17,8 @@ PHP NEWS
static variable). (Nikita)
. Fixed bug #79779 (Assertion failure when assigning property of string
offset by reference). (Nikita)
. Fixed bug #79792 (HT iterators not removed if empty array is destroyed).
(Nikita)
- Fileinfo:
. Fixed bug #79756 (finfo_file crash (FILEINFO_MIME)). (cmb)

16
Zend/tests/bug79792.phpt Normal file
View File

@ -0,0 +1,16 @@
--TEST--
Bug #79792: HT iterators not removed if empty array is destroyed
--FILE--
<?php
$a = [42];
foreach ($a as &$c) {
// Make the array empty.
unset($a[0]);
// Destroy the array.
$a = null;
}
?>
===DONE===
--EXPECTF--
Warning: Invalid argument supplied for foreach() in %s on line %d
===DONE===

View File

@ -1627,11 +1627,11 @@ ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
}
} while (++p != end);
}
zend_hash_iterators_remove(ht);
SET_INCONSISTENT(HT_DESTROYED);
} else if (EXPECTED(HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED)) {
goto free_ht;
}
zend_hash_iterators_remove(ht);
SET_INCONSISTENT(HT_DESTROYED);
efree(HT_GET_DATA_ADDR(ht));
free_ht:
FREE_HASHTABLE(ht);