Skip to content

Commit 1ce5cf1

Browse files
committed
Fix memory leak on failure to open
Fixes leak of memory caused by failure to free file and directory structures when open fails.
1 parent 8c8bcf2 commit 1ce5cf1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ bool File::_open_file (char const *filepath, uint8_t mode)
6666
{
6767
// failed to open
6868
PRINT_LFS_ERR(rc);
69+
// free memory
70+
rtos_free(_file);
6971
return false;
7072
}
7173

@@ -89,6 +91,8 @@ bool File::_open_dir (char const *filepath)
8991
{
9092
// failed to open
9193
PRINT_LFS_ERR(rc);
94+
// free memory
95+
rtos_free(_dir);
9296
return false;
9397
}
9498

0 commit comments

Comments
 (0)