m-lua-scripting: check argument type is table to avoid crashing

In conf_apply_rules, check input argument is a table before assuming it
is and potentially crashing.

Add check also in wplua_table_to_properties to avoid similar bugs.
This commit is contained in:
Pauli Virtanen
2023-10-13 22:35:41 +03:00
parent 4ad263b16c
commit b65f8884a5
2 changed files with 6 additions and 0 deletions

View File

@@ -17,6 +17,11 @@ wplua_table_to_properties (lua_State *L, int idx)
const gchar *key, *value;
int table = lua_absindex (L, idx);
if (lua_type (L, table) != LUA_TTABLE) {
wp_critical ("skipping non-table value");
return p;
}
lua_pushnil(L);
while (lua_next (L, table) != 0) {
/* copy key & value to convert them to string */