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:
parent
8c8bcf292e
commit
1ce5cf13d2
1 changed files with 4 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue