bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] gawk-5.0.0: use-of-uninitialized-value


From: arnold
Subject: Re: [bug-gawk] gawk-5.0.0: use-of-uninitialized-value
Date: Fri, 21 Jun 2019 07:07:20 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Hi.

"Andrew J. Schorr" <address@hidden> wrote:

> Thanks for chasing this down. I have two questions:
>
> 1. Mightn't it be more efficient to use ezalloc instead of emalloc+memset?

It's the same thing under the hood I bet, but it would make the
code clearer. Feel free to push a patch. (I sorta thought about it
but was lazy.)

> 2. I had noticed that the valgrind complaint occurred only when the
> program file contained 'A', but not when it contained 'A\n'. There was
> also no complaint when 'A' was supplied on the command line. But I didn't
> debug further. Why did the absence of a newline at the end of a file
> make a difference, or the fact that it was in a file instead of on the
> command line? It seems a bit odd.

Only at first glance, Watson, only at first glance. (:-)

The problem was reading past initialized memory.  In the case of
'A\n' the byte after the A is initialized. In  the case of 'A' on
the command line, the lexer appends a final newline so that the
grammar sees a full statement. So the memory there is also initialized.

> I wonder if zapping the memory is just covering up a subtle problem...

I don't think so.

Thanks,

Arnold



reply via email to

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