From e53b74c0e2b6bca7de2d58bf15d563f3c074a496 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Fri, 6 Dec 2019 16:15:03 +0100 Subject: [PATCH] :art: Check for null tick --- src/lib/modules.c | 5 ++++- tests/UsrUgen/null_tick.gw | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/UsrUgen/null_tick.gw diff --git a/src/lib/modules.c b/src/lib/modules.c index f6e7bee8..48d692a9 100644 --- a/src/lib/modules.c +++ b/src/lib/modules.c @@ -247,13 +247,16 @@ static INSTR(UsrUGenTick) { if(uu->shred) free_vm_shred(uu->shred); UGEN(o)->module.gen.tick = usrugen_tick; + const VM_Code code = *(VM_Code*)(shred->reg-offset); + release(o, shred); + if(!code) + Except(shred, "[NullTickException]"); uu->shred = new_vm_shred(shred->info->vm->gwion->mp, *(VM_Code*)(shred->reg-offset)); ADD_REF(*(VM_Code*)(shred->reg - offset)); uu->shred->info->vm = shred->info->vm; code_prepare(uu->shred->code); shreduler_ini(uu->shred->info->vm->shreduler, uu->shred); uu->prep = instr->m_val ? member_prep : global_prep; - release(o, shred); *(M_Object*)(shred->reg - SZ_INT) = o; } diff --git a/tests/UsrUgen/null_tick.gw b/tests/UsrUgen/null_tick.gw new file mode 100644 index 00000000..6b2d7693 --- /dev/null +++ b/tests/UsrUgen/null_tick.gw @@ -0,0 +1,3 @@ +#! [contains] NullTickException +typedef float ptr_t(float); +ptr_t ptr ~= UsrUGen u; -- 2.43.0