pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid memcpy() with a NULL source pointer and count == 0
Date: Tue, 01 Dec 2020 14:47:39 +0000
Message-ID: <E1kk6wN-0002uB-E8@gemulon.postgresql.org> (raw)

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
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f0ff52f25cb9773de67303a77e6afe3b8a2c4d48

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



view thread (4+ messages)  latest in thread

Message-ID: <E1kk6wN-0002uB-E8@gemulon.postgresql.org>
Permalink:  ../E1kk6wN-0002uB-E8@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kk6wN-0002uB-E8@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Avoid memcpy() with a NULL source pointer and count == 0
  In-Reply-To: <E1kk6wN-0002uB-E8@gemulon.postgresql.org>
  References: <E1kk6wN-0002uB-E8@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox