]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: hlua: removing ambiguous lua_pushvalue with 0 index
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 7 Oct 2022 09:54:57 +0000 (11:54 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 12 Oct 2022 07:22:05 +0000 (09:22 +0200)
In cd341d531, I added a FIXME comment because I noticed a
lua_pushvalue with 0 index, whereas lua doc states that 0 is never
an acceptable index.

After reviewing and testing the hlua_applet_http_send_response() code,
it turns out that this pushvalue is not even needed.
So it's safer to remove it as it could lead to undefined
behavior (since it is not supported by Lua API) and it grows lua stack
by 1 for no reason.

No backport needed.

src/hlua.c

index 02cba1e6026367dbbdf7c7407d11d0254931e03a..ccdf5389664c9751c7dc5df554aec95824bf2ed2 100644 (file)
@@ -5377,8 +5377,6 @@ __LJMP static int hlua_applet_http_send_response(lua_State *L)
        sl->info.res.status = http_ctx->status;
 
        /* Get the array associated to the field "response" in the object AppletHTTP. */
-       /* FIXME: according to Lua doc, 0 is considered to be invalid index? */
-       lua_pushvalue(L, 0);
        if (lua_getfield(L, 1, "response") != LUA_TTABLE) {
                hlua_pusherror(L, "Lua applet http '%s': AppletHTTP['response'] missing.\n",
                               luactx->appctx->rule->arg.hlua_rule->fcn->name);