mirror of
https://github.com/postgres/postgres.git
synced 2026-06-04 22:32:45 -04:00
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.
This commit is contained in:
parent
762c143682
commit
d8f2858b88
2 changed files with 6 additions and 6 deletions
|
|
@ -127,20 +127,19 @@ dispell_lexize(PG_FUNCTION_ARGS)
|
|||
if (res == NULL)
|
||||
PG_RETURN_POINTER(NULL);
|
||||
|
||||
ptr = cptr = res;
|
||||
while (ptr->lexeme)
|
||||
cptr = res;
|
||||
for (ptr = cptr; ptr->lexeme; ptr++)
|
||||
{
|
||||
if (searchstoplist(&(d->stoplist), ptr->lexeme))
|
||||
{
|
||||
pfree(ptr->lexeme);
|
||||
ptr->lexeme = NULL;
|
||||
ptr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(cptr, ptr, sizeof(TSLexeme));
|
||||
if (cptr != ptr)
|
||||
memcpy(cptr, ptr, sizeof(TSLexeme));
|
||||
cptr++;
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
cptr->lexeme = NULL;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue