[PATCH] Reclaim _REENT_MP_P5S in _reclaim_reent

[email protected]
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
From: Chris Johns <[email protected]>

The change fixes a memory leak in threads that clean up using
_reclaim_reent.

RTEMS: Closes #4967
---
 newlib/libc/reent/reent.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/newlib/libc/reent/reent.c b/newlib/libc/reent/reent.c
index db80ca06e..6bb271b9a 100644
--- a/newlib/libc/reent/reent.c
+++ b/newlib/libc/reent/reent.c
@@ -59,6 +59,17 @@ _reclaim_reent (struct _reent *ptr)
 	}
       if (_REENT_MP_RESULT(ptr))
 	_free_r (ptr, _REENT_MP_RESULT(ptr));
+      if (_REENT_MP_P5S(ptr))
+        {
+         struct _Bigint *thisone, *nextone;
+         nextone = _REENT_MP_P5S(ptr);
+         while (nextone)
+           {
+             thisone = nextone;
+             nextone = nextone->_next;
+             _free_r (ptr, thisone);
+           }
+       }
 #ifdef _REENT_SMALL
       }
 #endif
-- 
2.37.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.