summaryrefslogtreecommitdiffstatshomepage
path: root/py/objarray.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-02-27 16:09:57 +1100
committerDamien George <damien.p.george@gmail.com>2017-02-27 16:09:57 +1100
commitf4a12dca58c53f11a6e89424a47158fe6e48ade9 (patch)
tree163a78728d62d83cce42f1a5ae2363a354c5c9f6 /py/objarray.c
parent23ccb3e12e3b7fe6b56785d1e17e9d990d1da86c (diff)
downloadmicropython-f4a12dca58c53f11a6e89424a47158fe6e48ade9.tar.gz
micropython-f4a12dca58c53f11a6e89424a47158fe6e48ade9.zip
py/objarray: Disallow slice-assignment to read-only memoryview.
Also comes with a test for this. Fixes issue #2904.
Diffstat (limited to 'py/objarray.c')
-rw-r--r--py/objarray.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/objarray.c b/py/objarray.c
index 1b590f3c05..a84a631519 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -418,6 +418,10 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
uint8_t* dest_items = o->items;
#if MICROPY_PY_BUILTINS_MEMORYVIEW
if (o->base.type == &mp_type_memoryview) {
+ if ((o->typecode & 0x80) == 0) {
+ // store to read-only memoryview not allowed
+ return MP_OBJ_NULL;
+ }
if (len_adj != 0) {
goto compat_error;
}