diff --git a/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp b/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp index 4f8d48567..43ed2d962 100644 --- a/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp +++ b/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp @@ -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; } @@ -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; }