[Top][All Lists]

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

Re: [bug-gawk] Special Comparisons: uninitialized array index

From: arnold
Subject: Re: [bug-gawk] Special Comparisons: uninitialized array index
Date: Mon, 07 Aug 2017 11:59:30 -0600
User-agent: Heirloom mailx 12.4 7/29/08

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

> Perhaps the patch should be:
> --- a/str_array.c
> +++ b/str_array.c
> @@ -165,7 +165,7 @@ str_lookup(NODE *symbol, NODE *subs)
>          * "Array indices are always strings."
>          * ....
>          */
> -       if (subs->stfmt != STFMT_UNUSED) {
> +       if (subs->stfmt != STFMT_UNUSED || subs == Nnull_string || 
> (subs->flags & NULL_FIELD)) {
>                 /* The string was generated using CONVFMT. */
>                 NODE *tmp;

That's the right one.

> Or maybe we need a macro or inlined function to test whether a value
> is unassigned, since this logic is also in the do_typeof function...

If we need to do such a test a third time, then we can add a macro
or function.  For now, this fixes the bug (which was pretty subtle
to start out with).  The MKS awk also got it wrong.

I will get this fix into master along with the test program.  With
this change typeof (correctly) reports string.

Thanks Daniel for the report and Andy for beating me to the fix.


reply via email to

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