-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix use-after-free in externref example #8410
Fix use-after-free in externref example #8410
Conversation
This fixes a typo in the `externref.c` example where a deallocated `wasmtime_val_t` was used by accident. Additionally this introduces scoping to prevent this from arising again.
examples/externref.c
Outdated
assert(item.kind == WASMTIME_EXTERN_TABLE); | ||
|
||
// Set `table[3]` to our `externref`. | ||
wasmtime_val_t externref_val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now declared inside this block, but then reused in the other block and has wasmtime_val_delete
called outside of the block. Can we move it up, out of this block then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait what how does this compile given this mistake...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah the answer is that it doesn't...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol yeah I was wondering myself
* Fix use-after-free in externref example This fixes a typo in the `externref.c` example where a deallocated `wasmtime_val_t` was used by accident. Additionally this introduces scoping to prevent this from arising again. * Run clang-format * Fix compilation of C example
* Fix use-after-free in externref example This fixes a typo in the `externref.c` example where a deallocated `wasmtime_val_t` was used by accident. Additionally this introduces scoping to prevent this from arising again. * Run clang-format * Fix compilation of C example
This fixes a typo in the
externref.c
example where a deallocatedwasmtime_val_t
was used by accident. Additionally this introduces scoping to prevent this from arising again.