Re: [PATCH] Fix possible overflow on tuplesort.c

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: [PATCH] Fix possible overflow on tuplesort.c
Дата
Msg-id 20200423194314.GA22975@alvherre.pgsql
обсуждение исходный текст
Ответ на [PATCH] Fix possible overflow on tuplesort.c  (Ranier Vilela <ranier.vf@gmail.com>)
Ответы Re: [PATCH] Fix possible overflow on tuplesort.c
Re: [PATCH] Fix possible overflow on tuplesort.c
Список pgsql-hackers
On 2020-Apr-16, Ranier Vilela wrote:

> When multiplying variables, the overflow will take place anyway, and only
> then will the meaningless product be explicitly promoted to type int64.
> It is one of the operands that should have been cast instead to avoid the
> overflow.
>
> -   if (state->availMem < (int64) ((newmemtupsize - memtupsize) * sizeof(SortTuple)))
> +   if (state->availMem < ((int64) (newmemtupsize - memtupsize) * sizeof(SortTuple)))

Doesn't sizeof() return a 64-bit wide value already?

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: HEAPDEBUGALL is broken
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [PATCH] FIx resource leaks (pg_resetwal.c)