Skip to content

Commit

Permalink
Merge pull request #827 from attermann/lfs_leak
Browse files Browse the repository at this point in the history
Fix memory leak on failure to open
  • Loading branch information
hathach committed Jul 18, 2024
2 parents 8c8bcf2 + 236e434 commit 11b6799
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ bool File::_open_file (char const *filepath, uint8_t mode)
{
// failed to open
PRINT_LFS_ERR(rc);
// free memory
rtos_free(_file);
_file = NULL;
return false;
}

Expand All @@ -89,6 +92,9 @@ bool File::_open_dir (char const *filepath)
{
// failed to open
PRINT_LFS_ERR(rc);
// free memory
rtos_free(_dir);
_dir = NULL;
return false;
}

Expand Down

0 comments on commit 11b6799

Please sign in to comment.