extmod/modmachine: Truncate integers that are to be stored using mem*.
Addresses issue #1835.
This commit is contained in:
parent
a888d5ab91
commit
3a042fb921
@ -79,7 +79,7 @@ STATIC mp_obj_t machine_mem_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t va
|
|||||||
} else {
|
} else {
|
||||||
// store
|
// store
|
||||||
uintptr_t addr = MICROPY_MACHINE_MEM_GET_WRITE_ADDR(index, self->elem_size);
|
uintptr_t addr = MICROPY_MACHINE_MEM_GET_WRITE_ADDR(index, self->elem_size);
|
||||||
uint32_t val = mp_obj_get_int(value);
|
uint32_t val = mp_obj_get_int_truncated(value);
|
||||||
switch (self->elem_size) {
|
switch (self->elem_size) {
|
||||||
case 1: (*(uint8_t*)addr) = val; break;
|
case 1: (*(uint8_t*)addr) = val; break;
|
||||||
case 2: (*(uint16_t*)addr) = val; break;
|
case 2: (*(uint16_t*)addr) = val; break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user