[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gawk: other double free(_wstr)
From: |
Karel Zak |
Subject: |
Re: gawk: other double free(_wstr) |
Date: |
Mon, 15 Jan 2007 13:03:07 +0100 |
User-agent: |
Mutt/1.5.11 |
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>
Re: gawk: other double free(_wstr), Aharon Robbins, 2007/01/13
Re: gawk: other double free(_wstr), Aharon Robbins, 2007/01/16
Re: gawk: other double free(_wstr), Aharon Robbins, 2007/01/18
Re: gawk: other double free(_wstr), Aharon Robbins, 2007/01/27