lua-decision: don't crash in table/select constructor if arg is not table.
authorJanos Kovacs <jankovac503@gmail.com>
Fri, 13 Dec 2013 12:35:42 +0000 (14:35 +0200)
committerKrisztian Litkey <kli@iki.fi>
Fri, 13 Dec 2013 12:35:42 +0000 (14:35 +0200)
src/core/lua-decision/mdb.c

index 23d02bb..763c210 100644 (file)
@@ -403,6 +403,9 @@ static int table_create_from_lua(lua_State *L)
 
     MRP_LUA_ENTER;
 
+    if (!lua_istable(L, 2))
+        luaL_error(L, "expecting table as argument");
+
     tbl = (mrp_lua_mdb_table_t *)mrp_lua_create_object(L, TABLE_CLASS, NULL,0);
 
     tbl->builtin = true;
@@ -925,6 +928,9 @@ static int select_create_from_lua(lua_State *L)
 
     MRP_LUA_ENTER;
 
+    if (!lua_istable(L, 2))
+        luaL_error(L, "expecting table as argument");
+
     sel = (mrp_lua_mdb_select_t *)mrp_lua_create_object(L,SELECT_CLASS,NULL,0);
 
     MRP_LUA_FOREACH_FIELD(L, 2, fldnam, fldnamlen) {