From a147e00f6d627eb456ab4a1da7c9c72b7b98ba9a Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Wed, 1 Dec 2021 21:54:00 +0100 Subject: [PATCH] Berry prevent crash when setting superclass of solidified class --- lib/libesp32/Berry/src/be_vm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/libesp32/Berry/src/be_vm.c b/lib/libesp32/Berry/src/be_vm.c index f00cc128a..dd60e34b7 100644 --- a/lib/libesp32/Berry/src/be_vm.c +++ b/lib/libesp32/Berry/src/be_vm.c @@ -984,7 +984,12 @@ newframe: /* a new call frame */ bvalue *a = RA(), *b = RKB(); if (var_isclass(a) && var_isclass(b)) { bclass *obj = var_toobj(a); - be_class_setsuper(obj, var_toobj(b)); + if (!gc_isconst(obj)) { + be_class_setsuper(obj, var_toobj(b)); + } else { + vm_error(vm, "internal_error", + "cannot change superclass of a read-only class"); + } } else { vm_error(vm, "type_error", "value '%s' does not support set super",