lua: don't crash if an iterator is NULL

simply behave as if the iterator is valid and has no items in it
This commit is contained in:
George Kiagiadakis
2021-06-02 19:37:32 +03:00
parent 9db0e741cd
commit a604ac4c0c

View File

@@ -391,7 +391,7 @@ iterator_next (lua_State *L)
{
WpIterator *it = wplua_checkboxed (L, 1, WP_TYPE_ITERATOR);
g_auto (GValue) v = G_VALUE_INIT;
if (wp_iterator_next (it, &v)) {
if (it && wp_iterator_next (it, &v)) {
return wplua_gvalue_to_lua (L, &v);
} else {
lua_pushnil (L);