RPM Community Forums

Mailing List Message of <popt-devel>

Re: POPT's API has designed in memory leaks. What to do?

From: Seonkon Choi <seonkon.choi@windriver.com>
Date: Mon 15 Feb 2016 - 16:32:46 CET
Message-ID: <20160215153246.GA22748@sel-schoi0-d2.wrs.com>
On Thu, Jun 17, 2010 at 10:09:37AM -0400, Jeff Johnson wrote:
> 
> On Jun 17, 2010, at 4:27 AM, Markdv wrote:
> 
> > 
> > I just don't see why you wouldn't want to "fix" this. Seems like all you'd have to do is add
> > 
> >    con->os->nextArg = _free(con->os->nextArg);
> > 
> > to poptFreeContext(poptContext con) and be done with it.
> > 
> 
> There's a double free with your suggested "fix" if/when the application
> has also free'd the memory returned.
> 
> 73 de Jeff
> 

Sorry Jeff,
could you please show me an example of double-free against with that "fix" ?

For the poptGetOptArg(), you mentioned,
	~snip~
	1554 char * poptGetOptArg(poptContext con)
	1555 {
	1556     char * ret = NULL;
	1557     if (con) {
	1558         ret = con->os->nextArg;
	1559         con->os->nextArg = NULL;
	1560     }
	1561     return ret;
	1562 }
	~snip~
So if someone called the poptGetOptArg(), _free(con->os->nextArg) of the poptResetContext() will do nothing.

I know, this thread is too old.
But it was talking about popt >= 1.16 and people still are using the popt-1.16.
So it is not too old to continue.
Received on Mon Feb 15 17:00:04 2016
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.