summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2024-11-28 15:13:52 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2024-11-28 15:13:52 +0900
commit319ac31529eb7bf7e5a4ef582c6f930bd8fca62e (patch)
tree9482c3c67f7ad579329c25bedeea64975e63df94
parent84bf0b37741fadd88c8ce8591e77476880dd209a (diff)
Assert that non-empty LINK_ANCHOR does not loop
After any `LINK_ELEMENT` sequence is added, `LINK_ANCHOR` must not loop.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12195
-rw-r--r--compile.c5
1 files changed, 5 insertions, 0 deletions
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