~nabijaczleweli/ossp-dev

Re: [CVS] OSSP: ossp-pkg/lmtp2nntp/ lmtp2nntp_option.c

Ralf S. Engelschall <rse@engelschall.com>
Details
Message ID
<20030211131311.GA49792@engelschall.com>
Sender timestamp
1044972791
DKIM signature
missing
Download raw message
On Tue, Feb 11, 2003, Thomas Lotterer wrote:

>     work around memory leak in popt
>
>   Summary:
>     Revision    Changes     Path
>     1.30        +1  -0      ossp-pkg/lmtp2nntp/lmtp2nntp_option.c
>   ____________________________________________________________________________
>
>   patch -p0 <<'@@ .'
>   Index: ossp-pkg/lmtp2nntp/lmtp2nntp_option.c
>   ============================================================================
>   $ cvs diff -u -r1.29 -r1.30 lmtp2nntp_option.c
>   --- ossp-pkg/lmtp2nntp/lmtp2nntp_option.c   11 Feb 2003 12:54:58 -0000  1.29
>   +++ ossp-pkg/lmtp2nntp/lmtp2nntp_option.c   11 Feb 2003 12:55:31 -0000  1.30
>   @@ -316,6 +316,7 @@
>            }
>            if ((option_find(o, i, &ocp) == OPTION_OK) && (ocp->cb != NULL)) {
>                rv = ocp->cb(ocp, cp = (ocp->type == OPT_FLAG ? NULL : (char *)popt_getoptarg(poptCon)), ocp->cbctx);
>   +            free(cp); /* TODO this should be the task of popt_freecontext but debugging showed popt does not free(3) */
>                if (rc == OPTION_OK)
>                    rc = rv;

Two things:

1. In your code "cp" can be NULL as far as I see it ("ocp->type == OPT_FLAG")
   and then you're performing a free(NULL) which some platforms hate greatly.
   So an "if (cp != NULL) free(cp)" would be better.

2. OSSP popt is derived from original POPT, but already with some cleanups
   and bugfixes. So feel free to fix the problem directly in OSSP popt
   if you think you do not break any other POPT things.

                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com
Reply to thread Export thread (mbox)