From 8097b3cc8a97b8b8a4be77e1fc5b5e7b3d58afb3 Mon Sep 17 00:00:00 2001 From: James Hillyerd Date: Fri, 4 Oct 2024 21:26:31 -0700 Subject: [PATCH] fix: ls.Get calls use top-relative index (#537) Signed-off-by: James Hillyerd --- pkg/extension/luahost/lua.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/extension/luahost/lua.go b/pkg/extension/luahost/lua.go index dd07cfd..189726f 100644 --- a/pkg/extension/luahost/lua.go +++ b/pkg/extension/luahost/lua.go @@ -165,7 +165,7 @@ func (h *Host) handleBeforeMailAccepted(addr event.AddressParts) *bool { return nil } - lval := ls.Get(1) + lval := ls.Get(-1) ls.Pop(1) logger.Debug().Msgf("Lua function returned %q (%v)", lval, lval.Type().String()) @@ -197,7 +197,8 @@ func (h *Host) handleBeforeMessageStored(msg event.InboundMessage) *event.Inboun return nil } - lval := ls.Get(1) + lval := ls.Get(-1) + ls.Pop(1) logger.Debug().Msgf("Lua function returned %q (%v)", lval, lval.Type().String()) if lval.Type() == lua.LTNil || lua.LVIsFalse(lval) { @@ -208,7 +209,6 @@ func (h *Host) handleBeforeMessageStored(msg event.InboundMessage) *event.Inboun if err != nil { logger.Error().Err(err).Msg("Bad response from Lua Function") } - ls.Pop(1) return result }