From 7f1217b2ab0e3ca86722ad23c6c42bfbf55ef5ec Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Oct 2024 21:56:08 +0200 Subject: [PATCH] Attempt to fix a lua panic when unarchiveing extvars (print error to console instead. Not sure if it would be safe for game to read from save afterwards though) https://github.com/alufolie91/saturn-32p/commit/a770ecdbd4afd56a9d8325eae47f0c69f71661ee#diff-0c6396d5a9ad45f461741cd44ffb2c0d3cf0eb2ec7b0500053005196fe53f1a6R1462 --- src/lua_script.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index b4d479658..2b96abe1e 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1149,7 +1149,13 @@ static void UnArchiveExtVars(UINT8 **p, void *pointer, boolean network) for (i = 0; i < field_count; i++) { READSTRING(*p, field); - UnArchiveValue(p, TABLESINDEX); + + if (UnArchiveValue(p, TABLESINDEX) == 1) + { + CONS_Alert(CONS_ERROR, "Unexpected end marker when reading ExtVars (field '%s')\n", field); + break; + } + lua_setfield(gL, -2, field); } }