From 2b97a03d4ca3b4ce52d2ddb00fc16bc7f679a2e0 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Tue, 14 Dec 2021 21:51:12 +0100 Subject: [PATCH] Latest Berry fixes --- lib/libesp32/berry/src/be_byteslib.c | 3 +++ lib/libesp32/berry/src/be_parser.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libesp32/berry/src/be_byteslib.c b/lib/libesp32/berry/src/be_byteslib.c index 82f4ab2be..17a5a7d4c 100644 --- a/lib/libesp32/berry/src/be_byteslib.c +++ b/lib/libesp32/berry/src/be_byteslib.c @@ -650,6 +650,9 @@ buf_impl bytes_check_data(bvm *vm, size_t add_size) { buf_impl attr = m_read_attributes(vm, 1); /* check if the `size` is big enough */ if (attr.len + (int32_t)add_size > attr.size) { + if (attr.fixed) { + be_raise(vm, BYTES_RESIZE_ERROR, BYTES_RESIZE_MESSAGE); + } /* it does not fit so we need to realocate the buffer */ bytes_resize(vm, &attr, attr.len + add_size); } diff --git a/lib/libesp32/berry/src/be_parser.c b/lib/libesp32/berry/src/be_parser.c index d2f2d7af5..094a5adef 100644 --- a/lib/libesp32/berry/src/be_parser.c +++ b/lib/libesp32/berry/src/be_parser.c @@ -174,7 +174,7 @@ void end_varinfo(bparser *parser, int beginpc) if (beginpc == -1) /* use block->beginpc by default */ beginpc = binfo->beginpc; /* skip the variable of the previous blocks */ - for (; it->beginpc < beginpc; ++it); + for (; (it <= end) && (it->beginpc < beginpc); ++it); for (; it <= end; ++it) { if (!it->endpc) /* write to endpc only once */ it->endpc = finfo->pc;