mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
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
This commit is contained in:
parent
5dc7faa91e
commit
ddba320059
@ -340,6 +340,7 @@ hstoreUniquePairs(Pairs *a, int32 l, int32 *buflen)
|
||||
{
|
||||
*buflen += res->keylen + ((res->isnull) ? 0 : res->vallen);
|
||||
res++;
|
||||
if (res != ptr)
|
||||
memcpy(res, ptr, sizeof(Pairs));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user