Skip to content

BUG: IMAP debug logger Close() without defer risks leak on panic #894

@andrinoff

Description

@andrinoff

Describe the bug

In fetcher/fetcher.go:1045-1046, the debug log file is opened and closed inline without defer:

_, _ = f.WriteString(msg)
_ = f.Close()

If a panic occurs between open and close (or if WriteString panics), the file descriptor leaks.

To reproduce

  1. Enable DEBUG_IMAP
  2. Trigger a panic during IMAP logging
  3. File descriptor leaked

Expected behavior

Use defer f.Close() immediately after opening the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingchoreMaintenance, refactor, cleanupgood first issueGood for newcomers

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions