Assert that non-empty LINK_ANCHOR does not loop

After any `LINK_ELEMENT` sequence is added, `LINK_ANCHOR` must not
loop.
This commit is contained in:
Nobuyoshi Nakada 2024-11-28 15:13:52 +09:00
parent 84bf0b3774
commit 319ac31529
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2024-11-28 07:51:28 +00:00

View File

@ -1290,10 +1290,15 @@ static void
APPEND_LIST(ISEQ_ARG_DECLARE LINK_ANCHOR *const anc1, LINK_ANCHOR *const anc2) APPEND_LIST(ISEQ_ARG_DECLARE LINK_ANCHOR *const anc1, LINK_ANCHOR *const anc2)
{ {
if (anc2->anchor.next) { if (anc2->anchor.next) {
/* LINK_ANCHOR must not loop */
RUBY_ASSERT(anc2->last != &anc2->anchor);
anc1->last->next = anc2->anchor.next; anc1->last->next = anc2->anchor.next;
anc2->anchor.next->prev = anc1->last; anc2->anchor.next->prev = anc1->last;
anc1->last = anc2->last; anc1->last = anc2->last;
} }
else {
RUBY_ASSERT(anc2->last == &anc2->anchor);
}
verify_list("append", anc1); verify_list("append", anc1);
} }
#if CPDEBUG < 0 #if CPDEBUG < 0