From fb996dd945074ec85e5e720a7e51d773b67fd6b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 22 Nov 2020 09:34:42 +0100 Subject: [PATCH] :art: Allow null $ Object in vararg --- src/lib/vararg.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/vararg.c b/src/lib/vararg.c index 41177b48..653c6e09 100644 --- a/src/lib/vararg.c +++ b/src/lib/vararg.c @@ -115,11 +115,15 @@ static INSTR(VarargCast) { if(!*(m_uint*)(o->data + SZ_INT)) Except(shred, "Using Vararg outside varloop"); struct Vararg_* arg = *(struct Vararg_**)o->data; - const Type t = (Type)instr->m_val; - if(isa((Type)vector_at(&arg->t, arg->i), t) < 0) + const Type t = (Type)instr->m_val, + u = (Type)vector_at(&arg->t, arg->i); + if(isa(u, t) > 0 || + (u == shred->info->vm->gwion->type[et_null] && + isa(t, shred->info->vm->gwion->type[et_object]) > 0)) { + for(m_uint i = 0; i < t->size; i += SZ_INT) + *(m_uint*)REG(i - SZ_INT) = *(m_uint*)(arg->d + arg->o + i); + } else Except(shred, "InvalidVariadicAccess"); - for(m_uint i = 0; i < t->size; i += SZ_INT) - *(m_uint*)REG(i - SZ_INT) = *(m_uint*)(arg->d + arg->o + i); } static OP_EMIT(opem_vararg_cast) { -- 2.43.0