bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] integer comparison/assignment bug


From: arnold
Subject: Re: [bug-gawk] integer comparison/assignment bug
Date: Sun, 01 Apr 2018 12:55:58 -0600
User-agent: Heirloom mailx 12.4 7/29/08

Noah Dean <address@hidden> wrote:

> I've been able to reproduce a consistent bug that causes my gawk to abort.
> Attached are a MWE of a simple data file, simple script, and the dump
> from the crash.  The print command in the 'END' section is not reached.

Hi. The patch below should fix the problem.

Thanks again for the report and the nice reproducer.

Arnold
---------------------
diff --git a/node.c b/node.c
index add959f..fcd2bf3 100644
--- a/node.c
+++ b/node.c
@@ -306,8 +306,24 @@ r_dupnode(NODE *n)
        }
 #endif
 
-       getnode(r);
-       *r = *n;
+#ifdef HAVE_MPFR
+       if ((n->flags & MPZN) != 0) {
+               r = mpg_integer();
+               mpz_set(r->mpg_i, n->mpg_i);
+               r->flags = n->flags;
+       } else if ((n->flags & MPFN) != 0) {
+               r = mpg_float();
+               int tval = mpfr_set(r->mpg_numbr, n->mpg_numbr, ROUND_MODE);
+               IEEE_FMT(r->mpg_numbr, tval);
+               r->flags = n->flags;
+       } else {
+#endif
+               getnode(r);
+               *r = *n;
+#ifdef HAVE_MPFR
+       }
+#endif
+
        r->flags |= MALLOC;
        r->valref = 1;
        /*



reply via email to

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