freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Frediano Ziglio <freddyz77 AT tin.it>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: RE: [freetds] dbstring_free memory leak
- Date: 07 Feb 2004 09:23:03 +0100
Il ven, 2004-02-06 alle 22:21, Lowden, James K ha scritto:
> > From: Frediano Ziglio [mailto:freddyz77 AT tin.it]
> > Sent: February 1, 2004 3:13 AM
> > >
> > > 1 dbstring_free(DBSTRING ** dbstrp)
> > > 2 {
> > > 3 if ((dbstrp != NULL) && (*dbstrp != NULL)) {
> > > 4 if ((*dbstrp)->strnext != NULL) {
> > > 5 dbstring_free(&((*dbstrp)->strnext));
> > > 6 }
> > > 7 free(*dbstrp);
> > > 8 *dbstrp = NULL;
> > > 9 }
> > > 10 }
>
> I saw your rewrite, and an opportunity to improve it, attached. Use it if
> you like it.
>
Your code
static void
dbstring_free(DBSTRING ** dbstrp)
{
DBSTRING *curr;
if (!dbstrp)
return;
for (curr = *dbstrp; curr; curr = curr->strnext) {
if (curr->strtext)
free(curr->strtext);
free(curr);
}
*dbstrp = NULL;
}
using curr = curr->strnext you access to a freed memory causing a possible
core.
freddy77
-
Re: [freetds] dbstring_free memory leak,
Frediano Ziglio, 02/01/2004
- <Possible follow-up(s)>
-
RE: [freetds] dbstring_free memory leak,
Lowden, James K, 02/06/2004
- RE: [freetds] dbstring_free memory leak, Frediano Ziglio, 02/07/2004
Archive powered by MHonArc 2.6.24.