Skip to content

Commit

Permalink
Add test that would have reproduced a use-after-free
Browse files Browse the repository at this point in the history
  • Loading branch information
squeek502 committed Mar 2, 2024
1 parent 3e39f98 commit ec6ecf5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test-fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ return require('lib/tap')(function (test)
assert(req)
end)

-- this previously hit a use-after-free
-- see https://github.com/luvit/luv/pull/696
test("fs.scandir given to new_work", function(print, p, expect, uv)
local req = assert(uv.fs_scandir('.'))
local work
work = assert(uv.new_work(function(_entries)
local _uv = require('luv')
while true do
if not _uv.fs_scandir_next(_entries) then break end
end
end, function() end))
work:queue(req)
end)

test("fs.realpath", function (print, p, expect, uv)
p(assert(uv.fs_realpath('.')))
assert(uv.fs_realpath('.', expect(function (err, path)
Expand Down

0 comments on commit ec6ecf5

Please sign in to comment.