Fix memory leak on failure to open

Fixes leak of memory caused by failure to free file and directory
structures when open fails.
This commit is contained in:
Chad Attermann 2024-07-12 12:42:53 -06:00
parent 8c8bcf292e
commit 1ce5cf13d2

View file

@ -66,6 +66,8 @@ bool File::_open_file (char const *filepath, uint8_t mode)
{
// failed to open
PRINT_LFS_ERR(rc);
// free memory
rtos_free(_file);
return false;
}
@ -89,6 +91,8 @@ bool File::_open_dir (char const *filepath)
{
// failed to open
PRINT_LFS_ERR(rc);
// free memory
rtos_free(_dir);
return false;
}