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: Aharon Robbins
Subject: Re: gawk: other double free(_wstr)
Date: Thu, 18 Jan 2007 22:27:37 +0200

This patch now applied. Thanks!

Arnold

> Date: Mon, 15 Jan 2007 13:03:07 +0100
> From: Karel Zak <address@hidden>
> Subject: Re: gawk: other double free(_wstr)
> To: "Andrew J. Schorr" <address@hidden>
> Cc: Aharon Robbins <address@hidden>, address@hidden
>
> On Sat, Jan 13, 2007 at 03:17:20PM -0500, Andrew J. Schorr wrote:
> > 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:
>
>  I agree with Aharon. It's more robust. There are places in code which
>  expect this behavior.
>
> > 
> > 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
>
>  Yes, the NODE is nothing nice and it should be splited to more
>  structs, but it's not trivial task.
>
> > you be certain that zeroing wstptr won't stomp on some other meaningful 
> > part of
> > the union?
>
>  Yes, but the NODE.type is the right way how gawk should be check type
>  of the node. I think the others ways are workarounds.
>
>  Suggestion:
>
> --- node.c.kzak       2007-01-15 12:53:07.000000000 +0100
> +++ node.c    2007-01-15 12:53:39.000000000 +0100
> @@ -778,6 +778,8 @@
>  void
>  free_wstr(NODE *n)
>  {
> +     assert(n->type == Node_val);
> +
>       if ((n->flags & WSTRCUR) != 0) {
>               assert(n->wstptr != NULL);
>               free(n->wstptr);
>
>
>
> -- 
>  Karel Zak  <address@hidden>
>
>
> #####################################################################################
> This Mail Was Scanned by 012.net AntiVirus Service4- Powered by TrendMicro 
> Interscan
>




reply via email to

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