Skip to content

Commit f5483c5

Browse files
authored
Merge pull request atomvm#507 from pguyot/w16/fix-nif_binary_split_2
Fix allocation bug in `nif_binary_split_2`
2 parents a64f2d3 + 09a28c2 commit f5483c5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libAtomVM/nifs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,8 +2648,8 @@ static term nif_binary_split_2(Context *ctx, int argc, term argv[])
26482648
int rest_size = bin_size - offset - pattern_size;
26492649
size_t rest_size_in_terms = term_sub_binary_heap_size(bin_term, rest_size);
26502650

2651-
// + 2 which is the result cons
2652-
if (UNLIKELY(memory_ensure_free(ctx, tok_size_in_terms + rest_size_in_terms + 2) != MEMORY_GC_OK)) {
2651+
// + 4 which is the result cons
2652+
if (UNLIKELY(memory_ensure_free(ctx, tok_size_in_terms + rest_size_in_terms + 4) != MEMORY_GC_OK)) {
26532653
RAISE_ERROR(OUT_OF_MEMORY_ATOM);
26542654
}
26552655

0 commit comments

Comments
 (0)