BUG/MINOR: httpclient/lua: return an error on argument check
src/hlua.c:7074:6: error: variable 'url_str' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
if (lua_type(L, -1) == LUA_TSTRING)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/hlua.c:7079:36: note: uninitialized use occurs here
hlua_hc->hc->req.url = istdup(ist(url_str));
^~~~~~~
Return an error on the stack if the argument is not a string.
diff --git a/src/hlua.c b/src/hlua.c
index b3f792c..e997964 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -7070,9 +7070,11 @@
if (lua_gettop(L) < 1 || lua_gettop(L) > 2)
WILL_LJMP(luaL_error(L, "'get' needs between 1 or 2 arguments"));
+ if (lua_type(L, -1) != LUA_TSTRING)
+ WILL_LJMP(luaL_error(L, "'get' takes an URL as a string arugment"));
+
/* arg 1: URL */
- if (lua_type(L, -1) == LUA_TSTRING)
- url_str = lua_tostring(L, -1);
+ url_str = lua_tostring(L, -1);
hlua_hc = hlua_checkhttpclient(L, 1);