]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: hlua: consume error object if ignored after a failing lua_pcall()
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 23 Jan 2026 09:58:26 +0000 (10:58 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Fri, 23 Jan 2026 10:23:37 +0000 (11:23 +0100)
commita66b4881d7cc128494cf4eff626ec4423abb0a65
treec0298fd40410682bef394a88a1ae094d6c54bed5
parent9e9083d0e2fd586dcd526d2180ecda533cd187ab
BUG/MINOR: hlua: consume error object if ignored after a failing lua_pcall()

We frequently use lua_pcall() to provide safe alternative functions
(encapsulated helpers) that prevent the process from crashing in case
of Lua error when Lua is executed from an unsafe environment.

However, some of those safe helpers don't handle errors properly. In case
of error, the Lua API will always put an error object on top of the stack
as stated in the documentation. This error object can be used to retrieve
more info about the error. But in some cases when we ignore it, we should
still consume it to prevent the stack from being altered with an extra
object when returning from the helper function.

It should be backported to all stable versions. If the patch doesn't apply
automatically, all that's needed is to check for lua_pcall() in hlua.c
and for other cases than 'LUA_OK', make sure that the error object is popped
from the stack before the function returns.
src/hlua.c