]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Avoid memcpy() with a NULL source pointer and count == 0
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 1 Dec 2020 14:46:56 +0000 (11:46 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 1 Dec 2020 14:46:56 +0000 (11:46 -0300)
commitf0ff52f25cb9773de67303a77e6afe3b8a2c4d48
treecb2e979509fc4252747ceec41e7b817a1abad468
parent50f338574242be955c79ed0b3e193ce3ff4cd5eb
Avoid memcpy() with a NULL source pointer and count == 0

When memcpy() is called on a pointer, the compiler is entitled to assume
that the pointer is not null, which can lead to optimizing nearby code
in potentially undesirable ways.  We still want such optimizations
(gcc's -fdelete-null-pointer-checks) in cases where they're valid.

Related: commit 13bba02271dc.

Backpatch to pg11, where this particular instance appeared.

Reported-by: Ranier Vilela <ranier.vf@gmail.com>
Reported-by: Zhihong Yu <zyu@yugabyte.com>
Discussion: https://postgr.es/m/CAEudQApUndmQkr5fLrCKXQ7+ib44i7S+Kk93pyVThS85PnG3bQ@mail.gmail.com
Discussion: https://postgr.es/m/CALNJ-vSdhwSM5f4tnNn1cdLHvXMVe_S+V3nR5GwNrmCPNB2VtQ@mail.gmail.com
src/backend/commands/indexcmds.c