From 8547cdaa0de17a2d774d2a6fb8a6af0624db2b9f Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Tue, 26 Apr 2022 23:01:10 +0200 Subject: [PATCH] Berry fix pointer warning --- lib/libesp32/berry/src/be_bytecode.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/libesp32/berry/src/be_bytecode.c b/lib/libesp32/berry/src/be_bytecode.c index 8cea36022..14599441d 100644 --- a/lib/libesp32/berry/src/be_bytecode.c +++ b/lib/libesp32/berry/src/be_bytecode.c @@ -214,8 +214,10 @@ static void save_proto_table(bvm *vm, void *fp, bproto *proto) { bproto **p = proto->ptab, **end; save_long(fp, proto->nproto); /* proto count */ - for (end = p + proto->nproto; p < end; ++p) { - save_proto(vm, fp, *p); + if (p) { + for (end = p + proto->nproto; p < end; ++p) { + save_proto(vm, fp, *p); + } } } @@ -223,9 +225,11 @@ static void save_upvals(void *fp, bproto *proto) { bupvaldesc *uv = proto->upvals, *end; save_byte(fp, proto->nupvals); /* upvals count */ - for (end = uv + proto->nupvals; uv < end; ++uv) { - save_byte(fp, uv->instack); - save_byte(fp, uv->idx); + if (uv) { + for (end = uv + proto->nupvals; uv < end; ++uv) { + save_byte(fp, uv->instack); + save_byte(fp, uv->idx); + } } }