arduino-libraries / SD

SD Library for Arduino
http://arduino.cc/
GNU General Public License v3.0
182 stars 155 forks source link

Fixes leak on creation/destruction of temporary objects #51

Closed mrjimenez closed 3 years ago

mrjimenez commented 6 years ago

When temporary File() objects are created, the programmer is not able to call close(). That made the SD library leak memory. To fix it properly, not only must we supply a destructor calling close(), but we must also not use a pointer to a SdFile, because the pointer gets copied to other objects (e.g. on a call to open()), and when this temporary object gets destructed, the buffer of the newly created object gets freed. This pull request fixes this issue.

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.