fabianoriccardi / ESPLogger

An Arduino library providing a minimal interface to log data on flash memory and SD cards with ESP8266 and ESP32.
GNU Lesser General Public License v2.1
84 stars 15 forks source link

issue in flush function when flushing is fail #5

Closed umeshwalkar closed 4 years ago

umeshwalkar commented 4 years ago

Hi,

Appreciated your effort for this library.

Please correct me if i am wrong. I have noticed a issue regarding freeing dynamically allocated memory for "buffer" when user application returns false to "flush". at line number 211 ("logger_spiffs.cpp") and 271 ("logger_sd.cpp"), we are returning with false without freeing "buffer".

either we can call free(buffer) at this line or simply we can avoid/comment "return false" statement. because anyway we are returning status of "successFlush" at bottom which is already tagged as "false".

probably, this could be better idea to allocate memory using char buffer[sizeLimitPerChunk]; I don't know if all platform can handle it, but ESP32+Arduino can handle this way.

Regards, Umesh

fabianoriccardi commented 4 years ago

Hi, Thank you for the clear explanation, I have just merge your pull request.