Skip to content

bug: Push leaks ReadCloser from PullBlob on both success and error paths #491

Description

@aftersnow

Description

In pkg/backend/push.go:175-189, src.PullBlob() returns an io.ReadCloser that is never explicitly closed — on both success and error paths.

The reader is wrapped with io.NopCloser(reader) before passing to dst.Blobs().Push(), so even when push closes the wrapper, the original content ReadCloser is not closed.

Code

content, err := src.PullBlob(ctx, repo, desc.Digest.String())
if err \!= nil {
    return err  // content not closed
}

reader := pb.Add(prompt, desc.Digest.String(), desc.Size, content)
// io.NopCloser means dst closing the wrapper does NOT close content
if err := dst.Blobs().Push(ctx, desc, io.NopCloser(reader)); err \!= nil {
    pb.Abort(desc.Digest.String(), err)
    return err  // content not closed
}
// success path: content also not closed

Fix

Add defer content.Close() immediately after the nil-error check.

Severity

Critical — resource leak under normal operation, not just error paths.

Activity

  1. added a commit that references this issue on Apr 17, 2026
    5f210e1
  2. added 2 commits that reference this issue on May 27, 2026
    2267166
    d6c0c5c
  3. added a commit that references this issue on Sep 1, 2026
    3cb3138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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