Assert success of alloc in deep_copy_* loops

Returning false here would leave the destination sequence in an
invalid state and may lead to leaked memory; until this is solved
properly it is safer to assert().
This commit is contained in:
Camden Dixie O'Brien 2024-10-26 19:15:17 +01:00
parent ecfbf2e5c4
commit 3a578e190f

View File

@ -46,10 +46,8 @@ static bool deep_copy_sequence(parse_sequence_t *dst, parse_sequence_t *src)
if (NULL == dst->contents) if (NULL == dst->contents)
return false; return false;
for (int i = 0; i < dst->count; ++i) { for (int i = 0; i < dst->count; ++i)
if (!deep_copy_term(&dst->contents[i], &src->contents[i])) assert(deep_copy_term(&dst->contents[i], &src->contents[i]));
return false;
}
return true; return true;
} }
@ -68,9 +66,8 @@ static bool deep_copy_term(parse_term_t *dst, parse_term_t *src)
return false; return false;
for (int i = 0; i < dst->subexpr.count; ++i) { for (int i = 0; i < dst->subexpr.count; ++i) {
if (!deep_copy_sequence( assert(deep_copy_sequence(
&dst->subexpr.contents[i], &src->subexpr.contents[i])) &dst->subexpr.contents[i], &src->subexpr.contents[i]));
return false;
} }
} }