Commit 9895509
committed
Use dtor instead of free_obj for ZipArchive
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:
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');1 parent e844e68 commit 9895509
2 files changed
+32
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1004 | 1004 | | |
1005 | 1005 | | |
1006 | 1006 | | |
1007 | | - | |
| 1007 | + | |
1008 | 1008 | | |
| 1009 | + | |
| 1010 | + | |
1009 | 1011 | | |
1010 | 1012 | | |
1011 | 1013 | | |
| |||
1034 | 1036 | | |
1035 | 1037 | | |
1036 | 1038 | | |
1037 | | - | |
1038 | 1039 | | |
1039 | 1040 | | |
1040 | 1041 | | |
| |||
3119 | 3120 | | |
3120 | 3121 | | |
3121 | 3122 | | |
3122 | | - | |
| 3123 | + | |
3123 | 3124 | | |
3124 | 3125 | | |
3125 | 3126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
0 commit comments