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);