bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gawk: other double free(_wstr)


From: Andrew J. Schorr
Subject: Re: gawk: other double free(_wstr)
Date: Sat, 13 Jan 2007 15:17:20 -0500
User-agent: Mutt/1.4.2.1i

On Sat, Jan 13, 2007 at 08:52:30PM +0200, Aharon Robbins wrote:
> I think I'm going to undo the part of free_wstr that only zeros the
> fields if the flag is set.

Hmmm, this code that you plan to restore (zeroing wstptr even if the
WSTRCUR flag is not set) seems to conflict with a statement you made
back in July:

On Tue, Jul 18, 2006 at 10:22:41PM +0300, Aharon Robbins wrote:
> I have not yet read all this thread. The intent is that n->wstptr is NOT
> valid if the WSTRCUR bit is clear. Or to flip it around, only if the bit
> is set should you mess with n->wstptr.

That statement makes a lot of sense to me.  The NODE is a big messy union; can
you be certain that zeroing wstptr won't stomp on some other meaningful part of
the union?

FWIW, I believe that this version of free_wstr is correct:

void
free_wstr(NODE *n)
{
        if ((n->flags & WSTRCUR) != 0) {
                assert(n->wstptr != NULL);
                free(n->wstptr);
                n->wstptr = NULL;
                n->wstlen = 0;
                n->flags &= ~WSTRCUR;
        }
}

Regards,
Andy




reply via email to

[Prev in Thread] Current Thread [Next in Thread]