Skip to Content.
Sympa Menu

freetds - RE: [freetds] dbstring_free memory leak

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • 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






Archive powered by MHonArc 2.6.24.

Top of Page