From 837a83bf1c0ea8315825b903075ba279997e5e8c Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 24 Jun 2013 11:34:03 +0000 Subject: [PATCH] * libc/reent/reent.c (_reclaim_reent): Free also _misc and _signal_buf. --- newlib/ChangeLog | 5 +++++ newlib/libc/reent/reent.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 461076ff6..a57bcd7ef 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2013-06-24 Terraneo Federico + + * libc/reent/reent.c (_reclaim_reent): Free also _misc and + _signal_buf. + 2013-06-24 Terraneo Federico * libc/include/sys/reent.h (_ATEXIT_INIT_PTR): Remove. diff --git a/newlib/libc/reent/reent.c b/newlib/libc/reent/reent.c index 9f5a8c0d3..b6c2abf02 100644 --- a/newlib/libc/reent/reent.c +++ b/newlib/libc/reent/reent.c @@ -87,6 +87,10 @@ _DEFUN (_reclaim_reent, (ptr), _free_r (ptr, ptr->_localtime_buf); if (ptr->_asctime_buf) _free_r (ptr, ptr->_asctime_buf); + if (ptr->_signal_buf) + _free_r (ptr, ptr->_signal_buf); + if (ptr->_misc) + _free_r (ptr, ptr->_misc); #endif #ifndef _REENT_GLOBAL_ATEXIT @@ -110,6 +114,11 @@ _DEFUN (_reclaim_reent, (ptr), if (ptr->_cvtbuf) _free_r (ptr, ptr->_cvtbuf); + /* We should free _sig_func to avoid a memory leak, but how to + do it safely considering that a signal may be delivered immediately + after the free? + if (ptr->_sig_func) + _free_r (ptr, ptr->_sig_func);*/ if (ptr->__sdidinit) { -- 2.43.5