Skip to content

Commit

Permalink
lua: fix memory leak in error_object:set_prev()
Browse files Browse the repository at this point in the history
By design, the error references its cause, see error_set_prev() in diag.c.
Referencing the error from error_set_prev() in error.lua is wrong.
Introduced by commit 2e3c81d ("error: use int64_t as reference
counter").

Closes tarantool#9694

NO_DOC=bugfix
NO_TEST=memory leak
  • Loading branch information
Gumix authored and sergepetrenko committed Feb 16, 2024
1 parent 24bc65d commit d08dbcb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## bugfix/lua

* Fixed a memory leak in `error_object:set_prev()` (gh-9694).
2 changes: 0 additions & 2 deletions src/lua/error.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,10 @@ local function error_set_prev(err, prev)
if not ffi.istype('struct error', prev) and prev ~= nil then
error("Usage: error1:set_prev(error2)")
end
ffi.C.error_ref(err)
local ok = ffi.C.error_set_prev(err, prev);
if ok ~= 0 then
error("Cycles are not allowed")
end

end

local error_fields = {
Expand Down

0 comments on commit d08dbcb

Please sign in to comment.