From 3028e2908f561b87eca2e652087d8fcea373e2a6 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Fri, 21 Jan 2022 17:16:06 -0600 Subject: [PATCH] Avoid possible infinite loop in rest destructuring. --- src/core/specials.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/specials.c b/src/core/specials.c index 7ebdeae9..f6bc6cd0 100644 --- a/src/core/specials.c +++ b/src/core/specials.c @@ -188,8 +188,8 @@ static int destructure(JanetCompiler *c, janetc_emit_ss(c, JOP_LENGTH, len, right, 0); /* loop condition - reuse arg slot for the condition result */ - int32_t label_loop_start = janetc_emit_sss(c, JOP_EQUALS, arg, argi, len, 0); - int32_t label_loop_cond_jump = janetc_emit_si(c, JOP_JUMP_IF, arg, 0, 0); + int32_t label_loop_start = janetc_emit_sss(c, JOP_LESS_THAN, arg, argi, len, 0); + int32_t label_loop_cond_jump = janetc_emit_si(c, JOP_JUMP_IF_NOT, arg, 0, 0); /* loop body */ janetc_emit_sss(c, JOP_GET, arg, right, argi, 0);