Skip to content

BUG: Manual Close() instead of defer leaks fds on error in update copy #1056

@andrinoff

Description

@andrinoff

Describe the bug

In main.go:3510-3525, the binary copy block opens two files and manually calls Close on every error path:

in, err := os.Open(binPath)
if err != nil { ... }
out, err := os.OpenFile(tmpNew, ...)
if err != nil { in.Close(); ... }
if _, err := io.Copy(out, in); err != nil { in.Close(); out.Close(); ... }
in.Close()
out.Close()

This is fragile — every future return needs the same dance. A close error is also discarded, masking failed flushes.

Expected behavior

Use defer for both files and report close errors (especially on out, where the close error is the only signal that pending data was actually flushed).

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions