summaryrefslogtreecommitdiff
path: root/libpanto-lua
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-07-03 13:01:25 -0600
committert <t@tjp.lol>2026-07-03 13:24:31 -0600
commit3ad5d90d0de2bfca6ef17b10202df070e660e3c3 (patch)
tree37e6dd5c9b9b89255a4151b929694907f1b573cd /libpanto-lua
parent51bbb62ce5d82c460c75adfc03813e84ce5183d3 (diff)
segfault fix
Diffstat (limited to 'libpanto-lua')
-rw-r--r--libpanto-lua/src/module.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/libpanto-lua/src/module.zig b/libpanto-lua/src/module.zig
index 910334f..a707ecd 100644
--- a/libpanto-lua/src/module.zig
+++ b/libpanto-lua/src/module.zig
@@ -488,7 +488,8 @@ fn buildAgent(L: *c.lua_State, box: *AgentBox) ConfigError!void {
) catch return error.AgentInit;
// Pin the store after Agent.init succeeds; the agent/session borrow it.
- c.lua_pushvalue(L, -1);
+ // `luaL_ref` pops the store userdata, leaving the newly created Agent
+ // userdata on top for `agentNew` to return.
box.store_ref = c.luaL_ref(L, LUA_REGISTRYINDEX);
// Ownership of the inner conversation moved into the agent; neuter the