SD Library Potential Memory Leak

I was looking through the SD libarary and I found what looks like a potential memory leak. When a file is opened a malloc() is performed to get memory. When a file is closed the memory is freed.

But… If the file object is destroyed before the file is closed, the memory is never freed.

My suggestion would be to modify the destructor as follows:

Old code:

File::~File(void) {
  //  Serial.print("Deleted file object");
}

New code:

File::~File(void) {
  close();
  //  Serial.print("Deleted file object");
}

Does this seek correct or am I way off here?

Does this seek correct or am I way off here?

Yes, it is correct. No, you are not way off. Not even a little off.

Thanks Jgoulder,

I reported it here - http://code.google.com/p/arduino/issues/detail?id=814&thanks=814&ts=1329044927 -