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

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: E1eIgLs-0006zi-JP@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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/bf84d940-90d4-de91-19dd-612e011007f4@fuzzy.cz

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/630aceda5be79551b6772ab230fddfc4edbb63eb

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

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-11-25 19:50:41 Re: pgsql: Generational memory allocator
Previous Message Tom Lane 2017-11-25 19:16:01 pgsql: Repair failure with SubPlans in multi-row VALUES lists.