From 1ce5cf13d27344461309581226c54b56ab99b0c9 Mon Sep 17 00:00:00 2001 From: Chad Attermann Date: Fri, 12 Jul 2024 12:42:53 -0600 Subject: [PATCH] Fix memory leak on failure to open Fixes leak of memory caused by failure to free file and directory structures when open fails. --- libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp b/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp index 4f8d48567..3091f477e 100644 --- a/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp +++ b/libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp @@ -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; }