diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2019-06-25 17:54:27 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2019-06-25 17:54:27 -0700 |
| commit | 2494bfdc8626aadb7d3197d165daf2569f3a8db1 (patch) | |
| tree | a262e8dabad6dbd3351c72caf93caf2a038d3944 /py/emitglue.c | |
| parent | 77355cbb2f5a3cc2b48468955774a830f18ecf39 (diff) | |
Validate raw code and mpy read length
Diffstat (limited to 'py/emitglue.c')
| -rw-r--r-- | py/emitglue.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/py/emitglue.c b/py/emitglue.c index 74bf8ddca..7708689dd 100644 --- a/py/emitglue.c +++ b/py/emitglue.c @@ -142,11 +142,12 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_ar fun = mp_obj_new_fun_asm(rc->n_pos_args, rc->data.u_native.fun_data, rc->data.u_native.type_sig); break; #endif - default: - // rc->kind should always be set and BYTECODE is the only remaining case - assert(rc->kind == MP_CODE_BYTECODE); + case MP_CODE_BYTECODE: fun = mp_obj_new_fun_bc(def_args, def_kw_args, rc->data.u_byte.bytecode, rc->data.u_byte.const_table); break; + default: + // All other kinds are invalid. + mp_raise_RuntimeError(translate("Corrupt raw code")); } // check for generator functions and if so wrap in generator object |
