Re: Fix overflow in DecodeInterval - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Fix overflow in DecodeInterval
Date
Msg-id 20220213035150.wusl6mmbeb3m3jpy@alap3.anarazel.de
Whole thread Raw
In response to Re: Fix overflow in DecodeInterval  (Joseph Koshakow <koshy44@gmail.com>)
Responses Re: Fix overflow in DecodeInterval  (Joseph Koshakow <koshy44@gmail.com>)
List pgsql-hackers
Hi,

On 2022-02-12 21:16:05 -0500, Joseph Koshakow wrote:
> I've attached the patch below.

Any reason for using int return types?


> +/* As above, but initial val produces years */
> +static int
> +AdjustYears(int val, struct pg_tm *tm, int multiplier)
> +{
> +    int            years;
> +    if (pg_mul_s32_overflow(val, multiplier, &years))
> +        return 1;
> +    if (pg_add_s32_overflow(tm->tm_year, years, &tm->tm_year))
> +        return 1;
> +    return 0;
>  }

particularly since the pg_*_overflow stuff uses bool?


Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Adding CI to our tree
Next
From: Andres Freund
Date:
Subject: Re: Rewriting the test of pg_upgrade as a TAP test - take three - remastered set