Skip to content

utils.read_file may hold onto fd #3196

@sepruko

Description

@sepruko

Description

require('nvim-tree.utils').read_file does not close fd if stat is falsy, potentially leaving hanging file descriptors.

Neovim version

NVIM v0.12.0-dev-582e071-dirty
Build type: Release
LuaJIT 2.1.1731601260

Operating system and version

Linux 6.6.87.2-microsoft-standard-WSL2

Windows variant

WSL

nvim-tree version

master

Clean room replication

vim.pack.add({ 'https://github.com/nvim-tree/nvim-tree.lua' }, { load = true })

Steps to reproduce

  1. nvim
  2. Do anything that makes nvim-tree.lua call require('nvim-tree.utils').read_file
  3. On the off chance that it fails to fstat(2), it leaves a hanging file descriptor

Expected behavior

require('nvim-tree.utils').read_file calls vim.loop.fs_close(fd) prior to returning, if stat is falsy.

Actual behavior

require('nvim-tree.utils').read_file does not call vim.loop.fs_close(fd) prior to returning, when stat is falsy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions