From 319ac31529eb7bf7e5a4ef582c6f930bd8fca62e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 28 Nov 2024 15:13:52 +0900 Subject: [PATCH] Assert that non-empty LINK_ANCHOR does not loop After any `LINK_ELEMENT` sequence is added, `LINK_ANCHOR` must not loop. --- compile.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compile.c b/compile.c index 7de791a033..bd691627e3 100644 --- a/compile.c +++ b/compile.c @@ -1290,10 +1290,15 @@ static void APPEND_LIST(ISEQ_ARG_DECLARE LINK_ANCHOR *const anc1, LINK_ANCHOR *const anc2) { if (anc2->anchor.next) { + /* LINK_ANCHOR must not loop */ + RUBY_ASSERT(anc2->last != &anc2->anchor); anc1->last->next = anc2->anchor.next; anc2->anchor.next->prev = anc1->last; anc1->last = anc2->last; } + else { + RUBY_ASSERT(anc2->last == &anc2->anchor); + } verify_list("append", anc1); } #if CPDEBUG < 0