public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Reclaim _REENT_MP_P5S in _reclaim_reent
@ 2023-11-20 10:23 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-11-20 10:23 UTC (permalink / raw)
  To: newlib-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=37e67d15950a52b096601e98081abc2b17bd3a2b

commit 37e67d15950a52b096601e98081abc2b17bd3a2b
Author:     Chris Johns <chrisj@rtems.org>
AuthorDate: Mon Nov 20 12:04:58 2023 +1100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Mon Nov 20 10:49:39 2023 +0100

    Reclaim _REENT_MP_P5S in _reclaim_reent
    
    The _REENT_MP_P5S blocks are allocated using Balloc via i2b and linked in the
    pow5mult call. As a result these blocks are not on the freelist managed by the
    Bfree call. This change fixes a memory leak in threads that clean up using
    _reclaim_reent.
    
    RTEMS: Closes #4967

Diff:
---
 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 db80ca06e369..74503fa59291 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-20 10:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-20 10:23 [newlib-cygwin/main] Reclaim _REENT_MP_P5S in _reclaim_reent Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).