RPM Community Forums

Mailing List Message of <popt-devel>

popt clarification on poptGetNextOpt()

From: Danny Sung <dannys@mail.com>
Date: Thu 06 Dec 2007 - 23:41:51 CET
Message-ID: <47587AAF.7090701@mail.com>
Hi, the popt source code references ewt@redhat.com as the maintainer, 
but that bounced, so hopefully this is the right place to send this...

Sorry if this is old news to people...  I /just/ discovered a memory 
leak in my use of poptGetNextOpt().  It wasn't clear from the man page 
that the calling function must deallocate this memory, so I added it 
(patch enclosed).

Is this the intended behavior?  If so, it seems that poptGetNextOpt()
should return "char *" instead of "const char *".


I'm referencing popt as included in rpm-4.4.2.1 and the version of popt
I'm using is 1.10.2.1-2.fc6

However, I did just check popt-1.12 in the fc8 project and saw the exact
same code, so I don't think it's changed in a while.

Thanks,
Danny

--- popt.3.orig	2007-11-29 13:26:14.904926497 -0800
+++ popt.3	2007-11-29 13:27:32.687138451 -0800
@@ -367,6 +367,7 @@
 .sp
 This function returns the argument given for the final option returned by
 .BR poptGetNextOpt() ", or it returns " NULL " if no argument was specified."
+The calling function is responsible for deallocating this string.
 .sp
 .SS "4. LEFTOVER ARGUMENTS"
 Many applications take an arbitrary number of command-line arguments,
Received on Fri Dec 7 01:06:17 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.