]> granicus.if.org Git - esp-idf/commit
Merge branch 'bugfix/newlib_fd_memory_leak' into 'master'
authorIvan Grokhotkov <ivan@espressif.com>
Tue, 20 Sep 2016 04:12:06 +0000 (12:12 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Tue, 20 Sep 2016 04:12:06 +0000 (12:12 +0800)
commit6ca02748ac5c642a3858e052f0adfc17ccaf7be8
tree3acbe77543a6bdb0aa7d3579b40a3e3e56a6d8ed
parentb1ac1448740186620533ce45e92616bb1a593daf
parente8ae38024d5a13c3090f1ad500e48fb2143da3e8
Merge branch 'bugfix/newlib_fd_memory_leak' into 'master'

override per-task __cleanup handler to close stdin, stdout, stderr

Default _cleanup_r function (called from _reclaim_reent) calls _fclose_r for all file descriptors related to a particular instance of struct _reent.
It does that by calling _fwalk_reent, which iterates over __sglue list in struct _reent and calls _fclose_r for each member. But _stdin, _stdout, and _stderr are not in this list, so _fclose_r is not called for them. Which leads to a memory leak.
The easy way to fix this is to reset __cleanup member of struct _reent to our new “patched” version, which first calls the original version (_cleanup_r) and then does _fclose_r for each of the stdin, stdout, and stderr.

See merge request !94