[php-src] PR #17150: Fix GH-17137: Segmentation fault ext/phar/phar.c
| From: | nielsdos | Date: | Fri, 13 Dec 2024 20:28:21 +0000 |
| Subject: | [php-src] PR #17150: Fix GH-17137: Segmentation fault ext/phar/phar.c | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-29998@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/17150
Author: nielsdos
Commit edae2431 attempted to fix a leak and double free, but didn't properly understand what
was going on, causing a reference count mistake and subsequent segfault in this case.
The first mistake of that commit is that the reference count should've been increased because
we're reusing a phar object. The error handling path should've gotten changed instead to
undo this refcount increase instead of not refcounting at all (root cause of this bug).
The second mistake is that the alias isn't supposed to be transferred or whatever, that just
doesn't make sense. The reason the test bug69958.phpt originally leaked is because in the
non-reuse case we borrowed the alias and otherwise we own the alias. If we own the alias the alias
information shouldn't get deleted anyway as that would desync the alias map.
Fixing these will reveal a third issue in which the alias memory is not always properly in sync with
the persistence-ness of the phar, fix this as well.