Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/appstore/appstore_replicate_sinf.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,16 @@ func (t *appstore) replicateSinfFromInfo(info packageInfo, zip *zip.Writer, sinf

func (t *appstore) replicateZip(src *zip.ReadCloser, dst *zip.Writer) error {
for _, file := range src.File {
srcFile, err := file.OpenRaw()
srcFile, err := file.Open()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Close opened zip entry readers

replicateZip now uses file.Open(), which returns an io.ReadCloser, but the returned reader is never closed in the loop. On IPAs with many entries (or repeated calls via both ReplicateSinf and applyPatches), this leaves decompressor resources alive until GC and can cause avoidable memory growth/resource pressure; close srcFile after each copy (including error paths).

Useful? React with 👍 / 👎.

if err != nil {
return fmt.Errorf("failed to open raw file: %w", err)
return fmt.Errorf("failed to open file: %w", err)
}

header := file.FileHeader
dstFile, err := dst.CreateRaw(&header)
dstFile, err := dst.CreateHeader(&header)

if err != nil {
return fmt.Errorf("failed to create raw file: %w", err)
return fmt.Errorf("failed to create file: %w", err)
}

_, err = io.Copy(dstFile, srcFile)
Expand Down