Fixes leak on creation/destruction of temporary objects#92
Open
mrjimenez wants to merge 3 commits intoarduino-libraries:masterfrom
Open
Fixes leak on creation/destruction of temporary objects#92mrjimenez wants to merge 3 commits intoarduino-libraries:masterfrom
mrjimenez wants to merge 3 commits intoarduino-libraries:masterfrom
Conversation
The SD library was leaking memory due to the lack of destructor. There were subtle situations where temporary objects were created and destructed and the programmer had no chance to call close(). So, we need a destructor that calls close(). But to do so, we also need to change the pointer to SdFile to an actual SdFile object, otherwise the pointer will be copied and when one object is freed, the other object will loose its buffer too.
Author
|
It seems like you CI script has a problem: $ wget --directory-prefix="${HOME}/astyle" https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples_formatter.conf
--2021-04-10 04:48:14-- https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples_formatter.conf
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.109.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2021-04-10 04:48:14 ERROR 404: Not Found.
The command "wget --directory-prefix="${HOME}/astyle" https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples_formatter.conf" failed and exited with 8 during .
Your build has been stopped. |
Contributor
|
Hi @mrjimenez. You're right. The Travis CI configuration became outdated and this part of it was failing anyway due to previous contributors disregarding the results. Since it was planned for replacement, we didn't bother to update it. It will be resolved by #93 I the meantime, you can feel free to disregard the failure of this formatting check job. It's only the other jobs that matter, and I can see that they are all passing. Thanks so much for your contribution to the project! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.