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;