Skip to content

Commit 6c2744f

Browse files
committed
Use memmove() instead of memcpy() for copying overlapping regions.
In commit d2495f2, I fixed this bug in to_tsquery(), but missed the fact that plainto_tsquery() has the same bug.
1 parent dfb1e9b commit 6c2744f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/backend/tsearch/to_tsany.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS)
396396
if (query->size == 0)
397397
PG_RETURN_TSQUERY(query);
398398

399+
/* clean out any stopword placeholders from the tree */
399400
res = clean_fakeval(GETQUERY(query), &len);
400401
if (!res)
401402
{
@@ -405,6 +406,10 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS)
405406
}
406407
memcpy((void *) GETQUERY(query), (void *) res, len * sizeof(QueryItem));
407408

409+
/*
410+
* Removing the stopword placeholders might've resulted in fewer
411+
* QueryItems. If so, move the operands up accordingly.
412+
*/
408413
if (len != query->size)
409414
{
410415
char *oldoperand = GETOPERAND(query);
@@ -413,7 +418,7 @@ plainto_tsquery_byid(PG_FUNCTION_ARGS)
413418
Assert(len < query->size);
414419

415420
query->size = len;
416-
memcpy((void *) GETOPERAND(query), oldoperand, lenoperand);
421+
memmove((void *) GETOPERAND(query), oldoperand, lenoperand);
417422
SET_VARSIZE(query, COMPUTESIZE(len, lenoperand));
418423
}
419424

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy