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

Fix memory leak on failure to open #827

Merged
merged 2 commits into from
Jul 18, 2024
Merged

Conversation

attermann
Copy link
Contributor

Fixes leak of memory caused by failure to free file and directory structures when open fails.

Fixes leak of memory caused by failure to free file and directory
structures when open fails.
Clearing `_file` and `_dir` pointers after freeing on failure to open
just in case close() is later called.

To elaborate, the `_file` and `_dir` pointers are normally freed and
cleared by _close(), but when a failure occurs upon opening, these
pointers were being left orphaned since calling close() after failure to
open doesn't make much sense, and indeed caused serious issues within
lfs.
Copy link
Member

@hathach hathach left a comment

Choose a reason for hiding this comment

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

look good, thank you

PS: ci failed with nrf52832 due to issue with tinyusb library, fixed in other repo. Should be safe to merge

@hathach hathach merged commit 11b6799 into adafruit:master Jul 18, 2024
7 of 8 checks passed
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