aboutsummaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2023-11-20 12:04:58 +1100
committerCorinna Vinschen <corinna@vinschen.de>2023-11-20 10:49:39 +0100
commit37e67d15950a52b096601e98081abc2b17bd3a2b (patch)
tree8ad59aff6da2aa6efc2cbe3cc88ed6751aabddf6 /newlib
parent643275ed18b7ddab73bc7dcb0d971b7d4b1db392 (diff)
downloadnewlib-37e67d15950a52b096601e98081abc2b17bd3a2b.zip
newlib-37e67d15950a52b096601e98081abc2b17bd3a2b.tar.gz
newlib-37e67d15950a52b096601e98081abc2b17bd3a2b.tar.bz2
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
Diffstat (limited to 'newlib')
-rw-r--r--newlib/libc/reent/reent.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/newlib/libc/reent/reent.c b/newlib/libc/reent/reent.c
index db80ca0..74503fa 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