Visitar URL original
fix(bingads): scope file descriptor cleanup to loop iteration in unzip by Bharrguv · Pull Request #7424 · rudderlabs/rudder-server · GitHub
Skip to content

fix(bingads): scope file descriptor cleanup to loop iteration in unzip - #7424

Open
Bharrguv wants to merge 1 commit into
rudderlabs:masterfrom
Bharrguv:fix/bingads-defer-in-loop-fd-leak
Open

Bharrguv wants to merge 1 commit into
rudderlabs:masterfrom
Bharrguv:fix/bingads-defer-in-loop-fd-leak

Conversation

@Bharrguv

Copy link
Copy Markdown

Summary

Fixes file descriptor leaks during zip extraction in Bing Ads audience and offline-conversions utility helpers caused by deferred Close() calls placed directly inside loop iterations.

Root Cause

In Go, defer is evaluated when the surrounding function returns, not when the current loop iteration terminates. In unzip(...) across both audience/util.go and offline-conversions/util.go:

for _, f := range r.File {
    rc, err := f.Open()
    ...
    defer rc.Close()

    file, err := os.OpenFile(...) // or os.Create(...)
    ...
    defer file.Close()
}

@contributor-support

Copy link
Copy Markdown

Thank you @Bharrguv for contributing this PR.
Please sign the Contributor License Agreement (CLA) before merging.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants