Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource leak #2051

Closed
QiAnXinCodeSafe opened this issue Mar 24, 2020 · 1 comment
Closed

Resource leak #2051

QiAnXinCodeSafe opened this issue Mar 24, 2020 · 1 comment
Assignees

Comments

@QiAnXinCodeSafe
Copy link

Stream is opened

f = fopen(filename, "r");

Opened file never closed

@Cyan4973
Copy link
Contributor

@felixhandte , this is part of newly added contrib/diagnose_corruption/check_flipped_bits tool.

It's a minor issue easily fixed.
More interesting, consider employing the nested-resources programming pattern, where all resources are created first (including fopen()), then checked, then action takes place, then all resources are released (including fopen()). This allows the action to feature multiple exit statements without a risk to forget releasing one resource.

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

No branches or pull requests

4 participants