[php-src] PR #11959: Fix #81992: SplFixedArray::setSize() causes use-after-free

From: Date: Mon, 14 Aug 2023 00:01:32 +0000
Subject: [php-src] PR #11959: Fix #81992: SplFixedArray::setSize() causes use-after-free
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-23367@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/11959 Author: nielsdos Upon resizing, the elements are destroyed from lower index to higher index. When an element contains an object with a destructor, that destructor can access a lower (i.e. already destroyed) element, causing a uaf. Set refcounted zvals to NULL after destroying them to avoid a uaf. Alternative solution I thought about: Maybe it's possible to do it in two passes. First run all destructors and then destroy everything. But I don't know off the top of my head if the engine supports that (in an easy way). It seems complicated, and would also be technically a BC break because the destructors see still alive data that they might've expected to be destroyed. The solution in this PR is BC-preserving because it previously just crashed instead of doing anything useful.

« previous php.git-pulls (#23367) next »