]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: hlua: fix invalid use of lua_pop on error paths
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 9 Aug 2023 08:11:49 +0000 (10:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 11 Aug 2023 17:00:55 +0000 (19:00 +0200)
commit12cf8d4db7f0d239caf7ff3d94b62da2d953495c
tree4453dc9fae661b5ead8f0aba8badd0aec423c099
parent7f80d518124af10a5f8734bcf801dffc49ee2a10
BUG/MINOR: hlua: fix invalid use of lua_pop on error paths

Multiple error paths made invalid use of lua_pop():

When the stack is emptied using lua_settop(0), lua_pop() (which is
implemented as a lua_settop() macro) should not be used right after,
because it could lead to invalid reads since the stack is already empty.

Unfortunately, some remnants from initial lua stack implementation kept
doing so, resulting in haproxy crashs on some lua runtime errors paths
from time to time (ie: ERRRUN, ERRMEM).

Moreover, the extra lua_pop() instruction, even if it was safe, is totally
pointless in such case.

Removing such unsafe lua_pop() statements when we know that the stack is
already empty.

This must be backported in every stable versions.
src/hlua.c