py/emitbc: Assert that a small int fits its encoding when emitting one.

Signed-off-by: Damien George <damien@micropython.org>
pull/8472/head
Damien George 2022-03-31 23:59:10 +11:00
rodzic 2e3f2045f9
commit e3de723e2d
1 zmienionych plików z 2 dodań i 0 usunięć

Wyświetl plik

@ -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,