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

call free() two times,and err on #821

Open
pt2go opened this issue May 7, 2023 · 1 comment
Open

call free() two times,and err on #821

pt2go opened this issue May 7, 2023 · 1 comment

Comments

@pt2go
Copy link

pt2go commented May 7, 2023

i have no idea if the file is already close,so i may be call lfs_file_close() two times.
and free() call two times too, this cause an error.
shell we just add one line to bypass ??

static int lfs_file_rawclose(lfs_t *lfs, lfs_file_t *file) {
.....
// clean up memory
if (!file->cfg->buffer) {
lfs_free(file->cache.buffer);
file->cache.buffer = NULL; //+++++++???
}

return err;

}

@geky
Copy link
Member

geky commented May 17, 2023

Hi @pt2go, thanks for creating an issue.

This discussion is related: #790

From my perspective these sort of user-protections are out of scope for now. Though given the related discussion maybe they should be added at some point behind a sort of LFS_USERFRIENDLY define or similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants