From d66473aeeb6e6e337762a32dafee28e56a1a2e28 Mon Sep 17 00:00:00 2001 From: Johny Mattsson Date: Mon, 30 Aug 2021 16:49:23 +1000 Subject: [PATCH] Fix broken LFS loading in Lua 5.3. Do not [lua_]assert() on things which have a side effect... --- components/lua/lua-5.3/lundump.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/lua/lua-5.3/lundump.c b/components/lua/lua-5.3/lundump.c index aa6404bc..6cb5c291 100644 --- a/components/lua/lua-5.3/lundump.c +++ b/components/lua/lua-5.3/lundump.c @@ -579,9 +579,10 @@ static void LoadAllProtos (LoadState *S) { S->pv[i] = LoadFunction(S, luaF_newproto(L), NULL); } /* generate the ROTable entries from first N constants; the last is a timestamp */ - lua_assert(n+1 == LoadInt(S)); + int nk = LoadInt(S); + lua_assert(n+1 == nk); ROTable_entry *entry_list = cast(ROTable_entry *, StoreGetPos(S)); - for (i = 0; i < n; i++) { + for (i = 0; i < nk - 1; i++) { // -1 to ignore timestamp lu_byte tt_data = LoadByte(S); TString *Tname = LoadString2(S, tt_data); const char *name = getstr(Tname) + OFFSET_TSTRING;