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:
parent
ecfbf2e5c4
commit
3a578e190f
@ -46,10 +46,8 @@ static bool deep_copy_sequence(parse_sequence_t *dst, parse_sequence_t *src)
|
||||
if (NULL == dst->contents)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < dst->count; ++i) {
|
||||
if (!deep_copy_term(&dst->contents[i], &src->contents[i]))
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < dst->count; ++i)
|
||||
assert(deep_copy_term(&dst->contents[i], &src->contents[i]));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -68,9 +66,8 @@ static bool deep_copy_term(parse_term_t *dst, parse_term_t *src)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < dst->subexpr.count; ++i) {
|
||||
if (!deep_copy_sequence(
|
||||
&dst->subexpr.contents[i], &src->subexpr.contents[i]))
|
||||
return false;
|
||||
assert(deep_copy_sequence(
|
||||
&dst->subexpr.contents[i], &src->subexpr.contents[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user