Skip to content

Commit f70738d

Browse files
committed
Fix SEGFAULT in nif_lists_reverse
A hardcoded `2` as roots count is invalid when nif is called as lists:reverse/1
1 parent 0848033 commit f70738d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libAtomVM/nifs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4935,7 +4935,7 @@ static term nif_lists_reverse(Context *ctx, int argc, term argv[])
49354935
RAISE_ERROR(BADARG_ATOM);
49364936
}
49374937

4938-
if (UNLIKELY(memory_ensure_free_with_roots(ctx, len * CONS_SIZE, 2, argv, MEMORY_CAN_SHRINK) != MEMORY_GC_OK)) {
4938+
if (UNLIKELY(memory_ensure_free_with_roots(ctx, len * CONS_SIZE, argc, argv, MEMORY_CAN_SHRINK) != MEMORY_GC_OK)) {
49394939
RAISE_ERROR(OUT_OF_MEMORY_ATOM);
49404940
}
49414941

0 commit comments

Comments
 (0)