pgsql: Avoid formally-undefined use of memcpy() in hstoreUniquePairs().

Lists: pgsql-committers
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid formally-undefined use of memcpy() in hstoreUniquePairs().
Date: 2017-11-25 19:43:00
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-committers

Avoid formally-undefined use of memcpy() in hstoreUniquePairs().

hstoreUniquePairs() often called memcpy with equal source and destination
pointers. Although this is almost surely harmless in practice, it's
undefined according to the letter of the C standard. Some versions of
valgrind will complain about it, and some versions of libc as well
(cf. commit ad520ec4a). Tweak the code to avoid doing that.

Noted by Tomas Vondra. Back-patch to all supported versions because
of the hazard of libc assertions.

Discussion: https://postgr.es/m/[email protected]

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5c38ddebd66bc239b23fe20d489fe03c9ebd4e28

Modified Files
--------------
contrib/hstore/hstore_io.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)