From 9fcd7c3ae4346ff909d6e8e5ea985ec1cf7643ce Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sun, 24 Oct 2021 10:23:36 +0200 Subject: [PATCH] Berry fix possible memory corruption --- lib/libesp32/Berry/src/be_vm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/libesp32/Berry/src/be_vm.c b/lib/libesp32/Berry/src/be_vm.c index 3d9d2db4d..a986ec58e 100644 --- a/lib/libesp32/Berry/src/be_vm.c +++ b/lib/libesp32/Berry/src/be_vm.c @@ -882,28 +882,34 @@ newframe: /* a new call frame */ binstance *obj = var_toobj(a); bstring *attr = var_tostr(b); if (!be_instance_setmember(vm, obj, attr, c)) { + reg = vm->reg; vm_error(vm, "attribute_error", "class '%s' cannot assign to attribute '%s'", str(be_instance_name(obj)), str(attr)); } + reg = vm->reg; dispatch(); } if (var_isclass(a) && var_isstr(b)) { bclass *obj = var_toobj(a); bstring *attr = var_tostr(b); if (!be_class_setmember(vm, obj, attr, c)) { + reg = vm->reg; vm_error(vm, "attribute_error", "class '%s' cannot assign to static attribute '%s'", str(be_class_name(obj)), str(attr)); } + reg = vm->reg; dispatch(); } if (var_ismodule(a) && var_isstr(b)) { bmodule *obj = var_toobj(a); bstring *attr = var_tostr(b); if (be_module_setmember(vm, obj, attr, c)) { + reg = vm->reg; dispatch(); } else { + reg = vm->reg; // fall through exception below } }