[PATCH] memory leak in _reclaim_reent
Federico Terraneo
fede.tft@hotmail.it
Sun Jun 23 21:05:00 GMT 2013
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
While looking at the reentrancy code I've found three variables that
are surely malloc'd, but are not freed in _reclaim_reent(). Of these,
two variables, _misc and _signal_buf, cause a leak only if
_REENT_SMALL is defined. The third one, _sig_func seems to always
cause a leak.
The patch for this is simple and is attached, but I have a doubt about
it regarding _sig_func (the table of function pointers to signal
handlers): what if a signal is raised during _reclaim_reent()? Without
this patch, _sig_func is not freed so memory is leaked but the table
remains valid. With this patch no memory is leaked but a signal after
the free may be a problem. I do not have an answer to this question.
If needed, I can provide an alternate patch to only free the first two
variables.
newlib/ChangeLog
2013-06-23 Terraneo Federico <fede.tft@hotmail.it>
* libc/reent/reent.c (_reclaim_reent): Free also _misc,
_signal_buf and _sig_func.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJRx2MlAAoJECkLFtN5Xr9fPMAH/3w3aFPBqrx5Pn8X6wM2sPn/
Ziwa4CYHe+UdRCQSxplLxnV6NHVt0D3cVK1wCdDI7bif82uaJsA62mi+naGZN3Ys
8xoMfFw1MHYZ3cYy/gOne4m9i+2mjtHt/PMgGgSL1/F6xLlGAgVuajHdYWDgkuY6
KT0S8xlIch+vtlXPPpnQOnDhR5/mjXQ0/8o+VMMTRS3EHv5cr1tnS7+UT5DNuyF+
qumZeNOidl9//mwggLdek83+p9HEZ02wM2I22GnFaY2p9iRXs04l+g8w2vz0xC9g
dKw+Vd0G3fgLK3/HaGuVLomI6KxUHpmIeyHEX1VhNDEtbsJzBTyuaqy5b/1istE=
=LgeH
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reclaim_reent.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20130623/0ae2aa42/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reclaim_reent.patch.sig
Type: application/octet-stream
Size: 287 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20130623/0ae2aa42/attachment.obj>
More information about the Newlib
mailing list