diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | awkgram.c | 13 | ||||
-rw-r--r-- | awkgram.y | 13 |
3 files changed, 25 insertions, 8 deletions
@@ -1,3 +1,10 @@ +2014-01-28 Arnold D. Robbins <arnold@skeeve.com> + + * awkgram.y (negate_num): If just a double, return. Fixes a bug + that showed up on 32-bit systems with MPFR. Thanks to Eli Zaretskii + and Corinna Vinschen for the report. Also, free the MPZ integer. + Thanks to valgrind for the report. + 2014-01-24 Arnold D. Robbins <arnold@skeeve.com> * configure.ac, field.c: Update copyright year. @@ -4514,10 +4514,13 @@ negate_num(NODE *n) { int tval = 0; - if (! is_mpg_number(n)) + if (! is_mpg_number(n)) { n->numbr = -n->numbr; + return; + } + #ifdef HAVE_MPFR - else if (is_mpg_integer(n)) { + if (is_mpg_integer(n)) { if (! iszero(n)) { mpz_neg(n->mpg_i, n->mpg_i); return; @@ -4526,9 +4529,11 @@ negate_num(NODE *n) /* * 0 --> -0 conversion. Requires turning the MPG integer * into an MPFR float. - * - * So, convert and fall through. */ + + mpz_clear(n->mpg_i); /* release the integer storage */ + + /* Convert and fall through. */ tval = mpfr_set_d(n->mpg_numbr, 0.0, ROUND_MODE); IEEE_FMT(n->mpg_numbr, tval); n->flags &= ~MPZN; @@ -1966,10 +1966,13 @@ negate_num(NODE *n) { int tval = 0; - if (! is_mpg_number(n)) + if (! is_mpg_number(n)) { n->numbr = -n->numbr; + return; + } + #ifdef HAVE_MPFR - else if (is_mpg_integer(n)) { + if (is_mpg_integer(n)) { if (! iszero(n)) { mpz_neg(n->mpg_i, n->mpg_i); return; @@ -1978,9 +1981,11 @@ negate_num(NODE *n) /* * 0 --> -0 conversion. Requires turning the MPG integer * into an MPFR float. - * - * So, convert and fall through. */ + + mpz_clear(n->mpg_i); /* release the integer storage */ + + /* Convert and fall through. */ tval = mpfr_set_d(n->mpg_numbr, 0.0, ROUND_MODE); IEEE_FMT(n->mpg_numbr, tval); n->flags &= ~MPZN; |