Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad7b48e

Browse files
committed
Avoid memcpy() with same source and destination address.
The behavior of that is undefined, although unlikely to lead to problems inpractice.Found by running regression tests with Valgrind.
1 parent2b8483d commitad7b48e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

‎src/backend/tsearch/dict_ispell.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,19 @@ dispell_lexize(PG_FUNCTION_ARGS)
126126
if (res==NULL)
127127
PG_RETURN_POINTER(NULL);
128128

129-
ptr=cptr=res;
130-
while (ptr->lexeme)
129+
cptr=res;
130+
for (ptr=cptr;ptr->lexeme;ptr++)
131131
{
132132
if (searchstoplist(&(d->stoplist),ptr->lexeme))
133133
{
134134
pfree(ptr->lexeme);
135135
ptr->lexeme=NULL;
136-
ptr++;
137136
}
138137
else
139138
{
140-
memcpy(cptr,ptr,sizeof(TSLexeme));
139+
if (cptr!=ptr)
140+
memcpy(cptr,ptr,sizeof(TSLexeme));
141141
cptr++;
142-
ptr++;
143142
}
144143
}
145144
cptr->lexeme=NULL;

‎src/backend/utils/adt/tsvector.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ uniqueentry(WordEntryIN *a, int l, char *buf, int *outbuflen)
124124
buflen+=res->poslen*sizeof(WordEntryPos)+sizeof(uint16);
125125
}
126126
res++;
127-
memcpy(res,ptr,sizeof(WordEntryIN));
127+
if (res!=ptr)
128+
memcpy(res,ptr,sizeof(WordEntryIN));
128129
}
129130
elseif (ptr->entry.haspos)
130131
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp