Skip to content

Commit

Permalink
Fix memory leak on failure to open
Browse files Browse the repository at this point in the history
Fixes leak of memory caused by failure to free file and directory
structures when open fails.
  • Loading branch information
attermann committed Jul 12, 2024
1 parent 8c8bcf2 commit 1ce5cf1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 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,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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 1ce5cf1

Please sign in to comment.