summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-03-31 23:59:10 +1100
committerDamien George <damien@micropython.org>2022-03-31 23:59:10 +1100
commite3de723e2d955ca89c8b06bb2c4ae86724aad77b (patch)
tree4ec1bda963ce9bd0d4294c5d7dbaa517a42dec0b /py
parent2e3f2045f9a7511987e69a8be0d3d117502e4bb1 (diff)
py/emitbc: Assert that a small int fits its encoding when emitting one.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py')
-rw-r--r--py/emitbc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/py/emitbc.c b/py/emitbc.c
index 21ec12191..a9d5b3799 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -32,6 +32,7 @@
#include <assert.h>
#include "py/mpstate.h"
+#include "py/smallint.h"
#include "py/emit.h"
#include "py/bc0.h"
@@ -471,6 +472,7 @@ void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
}
void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg) {
+ assert(MP_SMALL_INT_FITS(arg));
if (-MP_BC_LOAD_CONST_SMALL_INT_MULTI_EXCESS <= arg
&& arg < MP_BC_LOAD_CONST_SMALL_INT_MULTI_NUM - MP_BC_LOAD_CONST_SMALL_INT_MULTI_EXCESS) {
emit_write_bytecode_byte(emit, 1,