From ade53925a616059f43b8d3f1dfcd0639e2e71132 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 22 Mar 2022 11:06:28 +0200 Subject: [PATCH] Lua: error when supplied coordinate is not table --- src/sp_lev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sp_lev.c b/src/sp_lev.c index e1193e045..18e51d7b3 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -5371,8 +5371,9 @@ boolean get_coord(lua_State *L, int i, lua_Integer *x, lua_Integer *y) { boolean ret = FALSE; + int ltyp = lua_type(L, i); - if (lua_type(L, i) == LUA_TTABLE) { + if (ltyp == LUA_TTABLE) { int arrlen; boolean gotx = FALSE; @@ -5407,6 +5408,9 @@ get_coord(lua_State *L, int i, lua_Integer *x, lua_Integer *y) return TRUE; } + } else if (ltyp != LUA_TNIL) { + /* non-existent coord is ok */ + nhl_error(L, "non-table coord specified"); } return ret; }