Skip to content

Release resources before returning #4401

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

Merged
merged 1 commit into from
Jun 4, 2025
Merged

Conversation

mugitya03
Copy link

In main, resources were freed on the success path but not in the error path. This change ensures all allocated resources are released before returning.

In main, resources were freed on the success path but not in the error path.
This change ensures all allocated resources are released before returning.
Copy link
Contributor

@Cyan4973 Cyan4973 left a comment

Choose a reason for hiding this comment

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

I understand that it's considered "proper" to clean all resources on exiting the function.
To be fair, since it's main(), it's leaving program execution immediately on return(). Hence all resources are going to be released anyway. So the benefit seems moot.

That being said, the complexity introduced is also quite low, so it's a reasonable trade off.

@Cyan4973 Cyan4973 merged commit bd89405 into facebook:dev Jun 4, 2025
101 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants