Skip to content

Commit

Permalink
Abort at load time on a decode case we currently don't support
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Guyot <[email protected]>
  • Loading branch information
pguyot committed Oct 16, 2023
1 parent f43a03a commit d6fa2ad
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/libAtomVM/opcodesswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,17 @@ typedef dreg_t dreg_gc_safe_t;
case COMPACT_11BITS_VALUE: \
(decode_pc)++; \
break; \
\
case COMPACT_NBITS_VALUE: \
/* TODO: when first_byte >> 5 is 7, a different encoding is used */ \
(decode_pc) += (first_byte >> 5) + 2; \
case COMPACT_NBITS_VALUE:{ \
int sz = (first_byte >> 5) + 2; \
if (UNLIKELY(sz > 8)) { \
/* TODO: when first_byte >> 5 is 7, a different encoding is used */ \
fprintf(stderr, "Unexpected nbits vaue @ %" PRIuPTR "\n", (uintptr_t) ((decode_pc) - 1)); \
AVM_ABORT(); \
break; \
} \
(decode_pc) += sz; \
break; \
\
} \
default: \
assert((first_byte & 0x30) != COMPACT_LARGE_INTEGER); \
break; \
Expand Down Expand Up @@ -244,7 +249,7 @@ typedef dreg_t dreg_gc_safe_t;
case COMPACT_XREG: \
case COMPACT_YREG: \
(dreg).index = first_byte >> 4; \
- break; \
break; \
case COMPACT_LARGE_YREG: \
(dreg).index = (((first_byte & 0xE0) << 3) | *(decode_pc)++); \
break; \
Expand Down

0 comments on commit d6fa2ad

Please sign in to comment.