Actions
Bug #9072
closed
VJ
VJ
lua: flowvar/flowint set() returns its argument (return 1 without pushing a result)
Bug #9072:
lua: flowvar/flowint set() returns its argument (return 1 without pushing a result)
Affected Versions:
Effort:
Difficulty:
Label:
Description
- Status: present in
main(9b7938aec) - Class: C-function stack-contract bug (misleading return value)
- Component:
src/util-lua-flowvarlib.c(LuaFlowvarSet),src/util-lua-flowintlib.c(LuaFlowintSet)
Description¶
Both setters end with return 1 but never push a result:
src/util-lua-flowvarlib.c:125
src/util-lua-flowintlib.c:112Lua takes wanted results from the top of the stack, so the returned value is the function's last argument: fv:set("abc") returns "abc", fv:set("abc", 2) returns 2, fi:set(5) returns 5. The docs document no return value, and if fv:set(...) then is always true, so scripts cannot detect success and can silently store a bogus value.
Reachable in rule lua: and output lua scripts whenever a flow is present (luaxform errors earlier on a missing flow).
Fix direction¶
return 0; (or push a boolean/nil and return 1).
Tests¶
lua-flowvar-set-return / lua-flowint-set-return: assert set() yields no value (or nil), never the argument.
Actions