Commit be5f710
authored
fix: use-after-free in cabi_realloc free_list on repeated export calls (#319)
cabi_realloc tracked all allocations in Runtime.free_list, which
post_call freed after each export invocation. When the host calls
cabi_realloc during an import to write a return value into guest
memory, those allocations may still be referenced by live JS objects
across repeated export calls. post_call would free them, causing
use-after-free on the next invocation.
Fix: remove indiscriminate tracking from cabi_realloc. Only the
retptr allocated explicitly in call() is tracked and freed by
post_call.
Fixes #2241 parent 499a888 commit be5f710
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | | - | |
146 | 144 | | |
147 | 145 | | |
148 | 146 | | |
| |||
233 | 231 | | |
234 | 232 | | |
235 | 233 | | |
| 234 | + | |
236 | 235 | | |
237 | 236 | | |
238 | 237 | | |
| |||
295 | 294 | | |
296 | 295 | | |
297 | 296 | | |
| 297 | + | |
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| |||
0 commit comments