From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id DA0573858D35; Mon, 20 Nov 2023 10:23:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA0573858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1700475790; bh=syRQFh54IT7qQLrtjySL7GKuYwhmyN6XcVCI8VctCn8=; h=From:To:Subject:Date:From; b=avcIF6rO4JLvjeeZ7k6pQYVYWqBgEMWklZrwl8oVgETlN+dO/gig3LKFLsnFxET2S 1g3B522Q9PAVhGSl7u0YAHUwHg9RvCslMryCm7NhFQXQQUYlzPtaQ/j8BoteSS9SWL 9ReU4oXtyLifL26+G0p4P2Wu+iNr5B6yyfEVLlZE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin/main] Reclaim _REENT_MP_P5S in _reclaim_reent X-Act-Checkin: newlib-cygwin X-Git-Author: Chris Johns X-Git-Refname: refs/heads/main X-Git-Oldrev: 643275ed18b7ddab73bc7dcb0d971b7d4b1db392 X-Git-Newrev: 37e67d15950a52b096601e98081abc2b17bd3a2b Message-Id: <20231120102310.DA0573858D35@sourceware.org> Date: Mon, 20 Nov 2023 10:23:10 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D37e67d15950= a52b096601e98081abc2b17bd3a2b commit 37e67d15950a52b096601e98081abc2b17bd3a2b Author: Chris Johns AuthorDate: Mon Nov 20 12:04:58 2023 +1100 Commit: Corinna Vinschen CommitDate: Mon Nov 20 10:49:39 2023 +0100 Reclaim _REENT_MP_P5S in _reclaim_reent =20 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 us= ing _reclaim_reent. =20 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 =3D _REENT_MP_P5S(ptr); + while (nextone) + { + thisone =3D nextone; + nextone =3D nextone->_next; + _free_r (ptr, thisone); + } + } #ifdef _REENT_SMALL } #endif