From 9e87e36ff06c928e79d12e7a1cb3346277cb4d70 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Thu, 5 May 2022 19:10:20 +0200 Subject: [PATCH] Berry fix crash with GC for ctype --- lib/libesp32/berry/src/be_gc.h | 2 +- lib/libesp32/berry/src/be_object.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libesp32/berry/src/be_gc.h b/lib/libesp32/berry/src/be_gc.h index 49e311291..1544041de 100644 --- a/lib/libesp32/berry/src/be_gc.h +++ b/lib/libesp32/berry/src/be_gc.h @@ -47,7 +47,7 @@ if (!gc_isconst(o)) { \ #define gc_exmark(o) (((o)->marked >> 4) & 0x0F) #define gc_setexmark(o, k) ((o)->marked |= (k) << 4) -#define be_isgcobj(o) (var_primetype(o) >= BE_GCOBJECT) +#define be_isgcobj(o) (var_primetype(o) >= BE_GCOBJECT && var_primetype(o) < BE_GCOBJECT_MAX) #define be_gcnew(v, t, s) be_newgcobj((v), (t), sizeof(s)) #define set_fixed(s) bbool _was_fixed = be_gc_fix_set(vm, cast(bgcobject*, (s)), 1) diff --git a/lib/libesp32/berry/src/be_object.h b/lib/libesp32/berry/src/be_object.h index 56bf03a9b..d9d777fe4 100644 --- a/lib/libesp32/berry/src/be_object.h +++ b/lib/libesp32/berry/src/be_object.h @@ -21,6 +21,7 @@ #define BE_FUNCTION 6 #define BE_GCOBJECT 16 /* from this type can be gced */ +#define BE_GCOBJECT_MAX (3<<5) /* from this type can't be gced */ #define BE_STRING 16 #define BE_CLASS 17