Skip to content

Commit ff1a110

Browse files
committed
Fix bug in decoding of literals in DECODE_COMPACT_TERM
Signed-off-by: Paul Guyot <[email protected]>
1 parent e993754 commit ff1a110

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/libAtomVM/opcodesswitch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ typedef union
121121
break; \
122122
\
123123
case 1: \
124-
dest_term = term_from_int4(((first_byte & 0xE0) << 3) | code_chunk[(base_index) + (off) + 1]); \
124+
dest_term = term_from_int(((first_byte & 0xE0) << 3) | code_chunk[(base_index) + (off) + 1]); \
125125
off += 2; \
126126
break; \
127127
\
@@ -425,7 +425,7 @@ typedef union
425425
break; \
426426
\
427427
case 1: \
428-
dest_term = term_from_int4(((first_byte & 0xE0) << 3) | code_chunk[(base_index) + (off) + 1]); \
428+
dest_term = term_from_int(((first_byte & 0xE0) << 3) | code_chunk[(base_index) + (off) + 1]); \
429429
off += 2; \
430430
break; \
431431
\

tests/erlang_tests/test_bs.erl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ start() ->
9191

9292
ok = test_iterate_binary(),
9393

94+
ok = test_large(),
95+
9496
0.
9597

9698
test_pack_small_ints({A, B, C}, Expect) ->
@@ -361,6 +363,11 @@ test_iterate_binary() ->
361363
traverse(<<"">>, Accum) -> Accum;
362364
traverse(<<H:8, T/binary>>, Accum) -> traverse(T, Accum ++ [H]).
363365

366+
test_large() ->
367+
X = <<42:1024>>,
368+
true = id(X) =:= <<42:1024>>,
369+
ok.
370+
364371
% Prevent optimization from the compiler
365372
id(X) ->
366373
Self = self(),

0 commit comments

Comments
 (0)