Skip to content

Commit e3de723

Browse files
committed
py/emitbc: Assert that a small int fits its encoding when emitting one.
Signed-off-by: Damien George <[email protected]>
1 parent 2e3f204 commit e3de723

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

py/emitbc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <assert.h>
3333

3434
#include "py/mpstate.h"
35+
#include "py/smallint.h"
3536
#include "py/emit.h"
3637
#include "py/bc0.h"
3738

@@ -471,6 +472,7 @@ void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok) {
471472
}
472473

473474
void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg) {
475+
assert(MP_SMALL_INT_FITS(arg));
474476
if (-MP_BC_LOAD_CONST_SMALL_INT_MULTI_EXCESS <= arg
475477
&& arg < MP_BC_LOAD_CONST_SMALL_INT_MULTI_NUM - MP_BC_LOAD_CONST_SMALL_INT_MULTI_EXCESS) {
476478
emit_write_bytecode_byte(emit, 1,

0 commit comments

Comments
 (0)