Skip to content

Commit 9598f36

Browse files
committed
py/emitnative: Add check that RHS of viper store is of integral type.
1 parent 94e4bd4 commit 9598f36

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

py/emitnative.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,10 @@ STATIC void emit_native_store_subscr(emit_t *emit) {
16981698
#else
16991699
emit_pre_pop_reg_flexible(emit, &vtype_value, &reg_value, reg_base, reg_index);
17001700
#endif
1701+
if (vtype_value != VTYPE_BOOL && vtype_value != VTYPE_INT && vtype_value != VTYPE_UINT) {
1702+
EMIT_NATIVE_VIPER_TYPE_ERROR(emit,
1703+
"can't store '%q'", vtype_to_qstr(vtype_value));
1704+
}
17011705
switch (vtype_base) {
17021706
case VTYPE_PTR8: {
17031707
// pointer to 8-bit memory
@@ -1784,6 +1788,10 @@ STATIC void emit_native_store_subscr(emit_t *emit) {
17841788
#else
17851789
emit_pre_pop_reg_flexible(emit, &vtype_value, &reg_value, REG_ARG_1, reg_index);
17861790
#endif
1791+
if (vtype_value != VTYPE_BOOL && vtype_value != VTYPE_INT && vtype_value != VTYPE_UINT) {
1792+
EMIT_NATIVE_VIPER_TYPE_ERROR(emit,
1793+
"can't store '%q'", vtype_to_qstr(vtype_value));
1794+
}
17871795
switch (vtype_base) {
17881796
case VTYPE_PTR8: {
17891797
// pointer to 8-bit memory

0 commit comments

Comments
 (0)