aboutsummaryrefslogtreecommitdiffstats
path: root/vm_core.h
diff options
context:
space:
mode:
authorYuta Saito <kateinoigakukun@gmail.com>2023-11-22 15:23:04 +0000
committerYuta Saito <kateinoigakukun@gmail.com>2023-11-23 02:18:53 +0900
commit295d648f766d46c5da059dac26b0373f986b6a28 (patch)
treee29f7929ea5d7350e779a3cf0abc66ad773eacf3 /vm_core.h
parent341321f11596dfef5e9af13fa1fad797fbfcdf67 (diff)
downloadruby-295d648f766d46c5da059dac26b0373f986b6a28.tar.gz
[wasm] Use xmalloc/xfree for jmpbuf allocation to trigger GC properly
`rb_vm_tag_jmpbuf_{init,deinit}` are safe to raise exception since the given tag is not yet pushed to `ec->tag` or already popped from it at the time, so `ec->tag` is always valid and it's safe to raise exception when xmalloc fails.
Diffstat (limited to 'vm_core.h')
-rw-r--r--vm_core.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/vm_core.h b/vm_core.h
index f7f0f7f2ca..fcac71b2e5 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -913,13 +913,13 @@ typedef rb_jmpbuf_t *rb_vm_tag_jmpbuf_t;
static inline void
rb_vm_tag_jmpbuf_init(rb_vm_tag_jmpbuf_t *jmpbuf)
{
- *jmpbuf = malloc(sizeof(rb_jmpbuf_t));
+ *jmpbuf = ruby_xmalloc(sizeof(rb_jmpbuf_t));
}
static inline void
rb_vm_tag_jmpbuf_deinit(const rb_vm_tag_jmpbuf_t *jmpbuf)
{
- free(*jmpbuf);
+ ruby_xfree(*jmpbuf);
}
#else
typedef rb_jmpbuf_t rb_vm_tag_jmpbuf_t;