Commit f235a27
committed
Fix GH-21776: use-after-free in zend_std_read_property magic __isset
When __isset drops the last non-temp reference to $this (e.g.
$GLOBALS['o'] = 0), the OBJ_RELEASE after the __isset call freed zobj
before zend_std_read_property reached the shared uninit_error check
at zend_lazy_object_must_init(zobj), a heap-use-after-free.
The GC_ADDREF/OBJ_RELEASE pair around __isset has been correct since
2018. The 2023 lazy-object support added a zobj read in the shared
fall-through path without extending the isset branch's ref coverage
to match. Defer the release via a local flag so zobj stays alive
through the lazy-init check and the recursive read on the initialized
instance. Route the two returns inside the lazy block through exit
so the deferred release runs on those paths too.
Closes GH-217761 parent 9c6ec37 commit f235a27
2 files changed
Lines changed: 24 additions & 3 deletions
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
742 | 742 | | |
743 | 743 | | |
744 | 744 | | |
| 745 | + | |
745 | 746 | | |
746 | 747 | | |
747 | 748 | | |
| |||
936 | 937 | | |
937 | 938 | | |
938 | 939 | | |
939 | | - | |
| 940 | + | |
940 | 941 | | |
941 | 942 | | |
942 | 943 | | |
| |||
998 | 999 | | |
999 | 1000 | | |
1000 | 1001 | | |
1001 | | - | |
| 1002 | + | |
1002 | 1003 | | |
1003 | 1004 | | |
1004 | 1005 | | |
1005 | | - | |
| 1006 | + | |
| 1007 | + | |
1006 | 1008 | | |
1007 | 1009 | | |
1008 | 1010 | | |
| |||
1015 | 1017 | | |
1016 | 1018 | | |
1017 | 1019 | | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
1018 | 1023 | | |
1019 | 1024 | | |
1020 | 1025 | | |
| |||
0 commit comments