[PR][php-src][#1175][PHP-5.5] - Fix bug #69227 and #65967
| From: | noreply@php.net | Date: | Fri, 13 Mar 2015 04:55:43 +0000 |
| Subject: | [PR][php-src][#1175][PHP-5.5] - Fix bug #69227 and #65967 | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-2737@lists.php.net to get a copy of this message | ||
You can view the Pull Request on github:
https://github.com/php/php-src/pull/1175
Pull Request Description:
See https://bugs.php.net/bug.php?id=69227
**The old**:
SplObjectStorage had a get_gc method that returns SplObjectStorage->properties. A hidden
\x00gcdata property is added as an array so the gc can iterate over the contents of the
collection. This was added to address https://bugs.php.net/bug.php?id=53071.
When a SplObjectStorage has a reference to itself in its collection (directly or indirectly) the gc
will fetch a copy of gcdata, then going depth first into its children it hits itself a second time
at which point it truncates the existing gcdata hash and fills it with the same data. This frees the
pointer being held by the first pass of gcdata. Use after free ensues.
**The new**:
This patch removes the hidden \x00gcdata property from SplObjectStorage, replacing it
with a list of zval*'s. Unlike a linked list updating the contents of a flat array does not
invalidate the callers reference. Also the values never really change as the underlying collection
does not change during gc
This fixes the free after use, and other bugs resulting from gcdata being a property (eg https://bugs.php.net/bug.php?id=65967)
This is broken in 5.* and master, but master will require a different patch as the gc has changed a
little.