From 31a841c323b0e9692695a57d4747f71a32b9fb68 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Tue, 3 Mar 2020 20:32:47 -0600 Subject: [PATCH] BUG/MINOR: lua: Add missing string length for lua sticktable lookup In hlua_stktable_lookup(), the key length is never set so all stktable:lookup("key") calls return nil from lua. This patch must be backported as far as 1.9. [Cf: I slightly updated the patch to use lua_tolstring() instead of luaL_checkstring() + strlen()] --- src/hlua_fcn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index faf9d7de0..a91406603 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -617,7 +617,7 @@ int hlua_stktable_lookup(lua_State *L) t = hlua_check_stktable(L, 1); smp.data.type = SMP_T_STR; smp.flags = SMP_F_CONST; - smp.data.u.str.area = (char *)luaL_checkstring(L, 2); + smp.data.u.str.area = (char *)lua_tolstring(L, 2, &smp.data.u.str.data); skey = smp_to_stkey(&smp, t); if (!skey) {