From 18fe17fa01da8ff8648733633056194e8c048d81 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Wed, 30 Jun 2021 19:32:43 +0300 Subject: [PATCH] lua: fail if an optional Interest is not none, nil, Interest or table --- modules/module-lua-scripting/api.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/module-lua-scripting/api.c b/modules/module-lua-scripting/api.c index ea26e378..137e1c88 100644 --- a/modules/module-lua-scripting/api.c +++ b/modules/module-lua-scripting/api.c @@ -643,15 +643,17 @@ static const luaL_Reg object_interest_methods[] = { static WpObjectInterest * get_optional_object_interest (lua_State *L, int idx, GType def_type) { - if (lua_isnil (L, idx)) + if (lua_isnoneornil (L, idx)) return NULL; else if (lua_isuserdata (L, idx)) return wplua_checkboxed (L, idx, WP_TYPE_OBJECT_INTEREST); else if (lua_istable (L, idx)) { object_interest_new_index (L, idx, def_type); return wplua_toboxed (L, -1); - } else + } else { + luaL_error (L, "expected Interest or none/nil"); return NULL; + } } /* WpObjectManager */