summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-03-07 13:13:33 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-03-07 13:29:47 +0200
commitc7a186e392d4654148a45eaf8ffbf026553ecbdb (patch)
treef450a3f0ee7c1386ba8903b48bd636025cb1a1ca /src/backend/utils/adt
parentff2e0e1f96ae412d06d0d10551161ca027d897fd (diff)
Avoid memcpy() with same source and destination address.
The behavior of that is undefined, although unlikely to lead to problems in practice. Found by running regression tests with Valgrind.
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r--src/backend/utils/adt/tsvector.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c
index 6810615a253..b28a32d69d0 100644
--- a/src/backend/utils/adt/tsvector.c
+++ b/src/backend/utils/adt/tsvector.c
@@ -125,7 +125,8 @@ uniqueentry(WordEntryIN *a, int l, char *buf, int *outbuflen)
buflen += res->poslen * sizeof(WordEntryPos) + sizeof(uint16);
}
res++;
- memcpy(res, ptr, sizeof(WordEntryIN));
+ if (res != ptr)
+ memcpy(res, ptr, sizeof(WordEntryIN));
}
else if (ptr->entry.haspos)
{