pgsql: Avoid memcpy() with a NULL source pointer and count == 0 - Mailing list pgsql-committers

From Alvaro Herrera
Subject pgsql: Avoid memcpy() with a NULL source pointer and count == 0
Date
Msg-id E1kk6wN-0002u7-DF@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/677f74e5bb8360122ebf2f473d7169ed65ce4dba

Modified Files
--------------
src/backend/commands/indexcmds.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)


pgsql-committers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: pgsql: docs: ulink all references to RFC's
Next
From: Tom Lane
Date:
Subject: pgsql: Ensure that expandTableLikeClause() re-examines the same table.