As reported by GH user @kanashimia in GH #3241, providing anything else
than a table to Patref:add_bulk() method could cause a segfault because
we were calling lua_next() with the lua object without ensuring it
actually is a table.
Let's add the missing lua_istable() check on the stack object before
calling lua_next() function on it.
It should be backported up to 3.2 with
884dc62 ("MINOR: hlua_fcn:
add Patref:add_bulk()")
int count = 0;
int ret;
+ if (!lua_istable(L, 2)) {
+ luaL_argerror(L, 2, "argument is expected to be a table");
+ return 0; // not reached
+ }
+
if ((ref->flags & HLUA_PATREF_FL_GEN) &&
pat_ref_may_commit(ref->ptr, ref->curr_gen))
curr_gen = ref->curr_gen;