pgsql: Avoid memcpy() with same source and destination during relmapper

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid memcpy() with same source and destination during relmapper
Date: 2020-12-18 20:47:13
Message-ID: E1kqMef-00069C-BF@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid memcpy() with same source and destination during relmapper init.

A narrow reading of the C standard says that memcpy(x,x,n) is undefined,
although it's hard to envision an implementation that would really
misbehave. However, analysis tools such as valgrind might whine about
this; accordingly, let's band-aid relmapper.c to not do it.

See also 5b630501e, d3f4e8a8a, ad7b48ea0, and other similar fixes.
Apparently, none of those folk tried valgrinding initdb? This has been
like this for long enough that I'm surprised it hasn't been reported
before.

Back-patch, just in case anybody wants to use a back branch on a platform
that complains about this; we back-patched those earlier fixes too.

Discussion: https://postgr.es/m/161790.1608310142@sss.pgh.pa.us

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/722eb325b9511e9d0a8669112c636edebe2cb01b

Modified Files
--------------
src/backend/utils/cache/relmapper.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2020-12-18 21:24:52 pgsql: Add a couple of missed .gitignore entries.
Previous Message Fujii Masao 2020-12-18 01:51:05 pgsql: pg_stat_statements: Track time at which all statistics were last