diff options
author | Victor Toso <me@victortoso.com> | 2015-10-07 22:04:16 +0200 |
---|---|---|
committer | Victor Toso <me@victortoso.com> | 2015-10-13 12:22:13 +0200 |
commit | 46148e12b08f6d02935e914db351b581e1589010 (patch) | |
tree | e68f095b0c3dff55527400a4bc2eafe6679e71ae | |
parent | fc5db9b06aba367ded7de5e0ce1762a7c312155b (diff) | |
download | grilo-plugins-46148e12b08f6d02935e914db351b581e1589010.tar.gz |
lua-factory: double check optional argument in fetch
Strange error on xml-parser tests when fetching mocked content. The
third argument was recognized as _G which is lua's table for its
environment.
Best thing to do is check number of arguments with lua_gettop instead of
relying on lua_istable.
https://bugzilla.gnome.org/show_bug.cgi?id=755447
-rw-r--r-- | src/lua-factory/grl-lua-library.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lua-factory/grl-lua-library.c b/src/lua-factory/grl-lua-library.c index 079344e..03978b7 100644 --- a/src/lua-factory/grl-lua-library.c +++ b/src/lua-factory/grl-lua-library.c @@ -992,12 +992,15 @@ grl_l_fetch (lua_State *L) const gchar *lua_callback; GrlNetWc *wc; gboolean is_table = FALSE; + gboolean wc_options = FALSE; OperationSpec *os; luaL_argcheck (L, (lua_isstring (L, 1) || lua_istable (L, 1)), 1, "expecting url as string or an array of urls"); luaL_argcheck (L, lua_isstring (L, 2), 2, "expecting callback function as string"); + /* Optional third argument */ + wc_options = (lua_gettop(L) == 3); os = grl_lua_library_get_current_operation (L); g_return_val_if_fail (os != NULL, 0); @@ -1035,7 +1038,7 @@ grl_l_fetch (lua_State *L) lua_callback = lua_tolstring (L, 2, NULL); - wc = net_wc_new_with_options(L, 3); + wc = (wc_options) ? net_wc_new_with_options(L, 3) : grl_net_wc_new (); /* shared data between urls */ results = g_new0 (gchar *, num_urls); |