Re: Bug in numeric_power() if exponent is INT_MIN

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Bug in numeric_power() if exponent is INT_MIN
Date: 2021-01-04 17:59:22
Message-ID: 3160982.1609783162@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
> The issue is in this line from power_var_int():
> sig_digits += (int) log(Abs(exp)) + 8;
> because "exp" is a signed int, so Abs(exp) leaves INT_MIN unchanged.
> The most straightforward fix is to use fabs() instead, so that "exp"
> is cast to double *before* the absolute value is taken, as in the
> attached patch.

Nice catch, and the fix seems appropriate.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Banck 2021-01-04 18:11:43 data_checksums enabled by default (was: Move --data-checksums to common options in initdb --help)
Previous Message Bruce Momjian 2021-01-04 17:56:18 Re: Proposed patch for key management