[php-src] PR #19602: Use dtor instead of free_obj for ZipArchive
| From: | iluuu1994 | Date: | Wed, 27 Aug 2025 03:52:00 +0000 |
| Subject: | [php-src] PR #19602: Use dtor instead of free_obj for ZipArchive | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-32938@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/19602
Author: iluuu1994
free_obj for objects referenced in the main symbol table may be called only once the executor has
already shut down. php_zip_cancel_callback() may attempt to invoke a user callback, which will
terminate the process because user code is not expected to be executed at this point. We solve this
by using the dtor_obj handler instead, which is called earlier in the shutdown sequence.
Technically, this allows some shenanigans with escaping __destruct functions, but given destructors
are useful, this may not be worth solving.
For reference:
```php
class MyZipArchive extends ZipArchive {
public function __destruct() {
global $leak;
$leak = $this;
}
}
new MyZipArchive;
$file = __DIR__ . '/gh18907.zip';
$leak->open($file, ZIPARCHIVE::CREATE);
$leak->addFromString('test', 'test');
```