mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
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.
This commit is contained in:
parent
d7df73a114
commit
79416cbd7a
@ -7070,8 +7070,10 @@ __LJMP static int hlua_httpclient_get(lua_State *L)
|
|||||||
if (lua_gettop(L) < 1 || lua_gettop(L) > 2)
|
if (lua_gettop(L) < 1 || lua_gettop(L) > 2)
|
||||||
WILL_LJMP(luaL_error(L, "'get' needs between 1 or 2 arguments"));
|
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 */
|
/* 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);
|
hlua_hc = hlua_checkhttpclient(L, 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user