[PATCH] Missing free() after tempnam() call (java.util.zip)

Diego 'Flameeyes' Pettenò flameeyes at gmail.com
Thu May 10 01:28:45 UTC 2007


(I hope this is the right mailing list for this, if it isn't, please
tell me where to post this :) )

I was looking at one warning coming from ld about the use of tmpname()
function rather than something like mkstemp, and while looking at that,
I found that the string returned by tempnam() was not being freed after
use.
I admit I don't have a Solaris box at hand to check if it's true there
too, but at least Linux's and FreeBSD's versions of tempnam() allocates
with malloc() the returned string. (My lack of a Solaris box at the
moment is what stops me from trying to use mkstemp() already; I'll try
to prepare a virtual machine with that as soon as I can).

The attached very very trivial patch fixes the leak by freeing the
string after use; it's a very small leak, but if I understand the code
well (but I won't bet I do) if a software uses that code repeatedly, it
might be significant.

Anyway, I hope this can be of help.

-- 
Diego "Flameeyes" Pettenò
http://farragut.flameeyes.is-a-geek.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openjdk-tempname-free.patch.patch
Type: text/x-patch
Size: 587 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20070510/07e06192/openjdk-tempname-free.patch.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20070510/07e06192/signature.asc>


More information about the core-libs-dev mailing list