[grilo-plugins/0.2.x] lua-factory: double check optional argument in fetch
- From: Victor Toso de Carvalho <victortoso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins/0.2.x] lua-factory: double check optional argument in fetch
- Date: Tue, 13 Oct 2015 10:24:15 +0000 (UTC)
commit 46148e12b08f6d02935e914db351b581e1589010
Author: Victor Toso <me victortoso com>
Date: Wed Oct 7 22:04:16 2015 +0200
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
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]