From 4cd1136f4c3a3a8f04851909edf057ade9f9f789 Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Mon, 8 May 2023 21:59:32 +0200 Subject: [PATCH] Berry fixed a rare condition when a GC causes a memory corruption (#18614) --- CHANGELOG.md | 1 + lib/libesp32/berry/src/be_string.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82af71df8..510561e5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file. ### Fixed - Partition_Manager.tapp fixed +- Berry fixed a rare condition when a GC causes a memory corruption ### Removed diff --git a/lib/libesp32/berry/src/be_string.c b/lib/libesp32/berry/src/be_string.c index 07a0fb162..ccc734ae3 100644 --- a/lib/libesp32/berry/src/be_string.c +++ b/lib/libesp32/berry/src/be_string.c @@ -195,6 +195,9 @@ static bstring* newshortstr(bvm *vm, const char *str, size_t len) } s = createstrobj(vm, len, 0); if (s) { + /* recompute size and list that may have changed due to a GC */ + size = vm->strtab.size; + list = vm->strtab.table + (hash & (size - 1)); memcpy(cast(char *, sstr(s)), str, len); s->extra = 0; s->next = cast(void*, *list);