Commit bb283ee
committed
Fix memory leak in by-ref foreach.
The issue occurs if a circular reference on the array var of a by-ref foreach is created,
all visible references to the array var are removed and the garbage collector is invoked before exiting the foreach.
Invoking the garbage collector removes the array var from the roots,
because the foreach statement itself is still holding a reference to it and thus it's still alive,
but when the foreach ends it does not re-add the array var to the GC roots, thus the GC cannot collect it and it leaks.
This PR fixes the issue by invoking the GC-aware zval destructor, which correctly adds the zval to the GC roots.
Fixes oss-fuzz #54515.1 parent bbfadd3 commit bb283ee
File tree
4 files changed
+21
-2
lines changed- Zend
- tests
4 files changed
+21
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3125 | 3125 | | |
3126 | 3126 | | |
3127 | 3127 | | |
3128 | | - | |
| 3128 | + | |
3129 | 3129 | | |
3130 | 3130 | | |
3131 | 3131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14317 | 14317 | | |
14318 | 14318 | | |
14319 | 14319 | | |
14320 | | - | |
| 14320 | + | |
14321 | 14321 | | |
14322 | 14322 | | |
14323 | 14323 | | |
| |||
0 commit comments