From: | Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH] Fix possible overflow on tuplesort.c |
Date: | 2020-04-23 20:03:47 |
Message-ID: | CAEudQAp-2pvSkq+co4e3w1e1Y_QwTUKwr14M2O1r_0GQ4-tFGA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Em qui., 23 de abr. de 2020 às 16:43, Alvaro Herrera <
alvherre(at)2ndquadrant(dot)com> escreveu:
> 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?
>
Sizeof return size_t.
Both versions are constant expressions of type std::size_t
<https://en.cppreference.com/w/cpp/types/size_t>.
regards,
Ranier Vilela
From | Date | Subject | |
---|---|---|---|
Next Message | James Coleman | 2020-04-23 20:12:34 | Re: [PATCH] Fix division by zero (explain.c) |
Previous Message | Tom Lane | 2020-04-23 19:57:39 | Re: [PATCH] Fix possible overflow on tuplesort.c |