Additionally clearing pointers just in case

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.
This commit is contained in:
Chad Attermann committed 2024-07-12 13:18:40 -06:00
1 parent 1ce5cf13d2
commit 236e434296
1 file changed
+2
@@ -68,6 +68,7 @@ bool File::_open_file (char const *filepath, uint8_t mode)
PRINT_LFS_ERR(rc);
// free memory
rtos_free(_file);
_file = NULL;
return false;
}
@@ -93,6 +94,7 @@ bool File::_open_dir (char const *filepath)
PRINT_LFS_ERR(rc);
// free memory
rtos_free(_dir);
_dir = NULL;
return false;
}