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

Commitd8f2858

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 parent762c143 commitd8f2858

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
@@ -127,20 +127,19 @@ dispell_lexize(PG_FUNCTION_ARGS)
127127
if (res==NULL)
128128
PG_RETURN_POINTER(NULL);
129129

130-
ptr=cptr=res;
131-
while (ptr->lexeme)
130+
cptr=res;
131+
for (ptr=cptr;ptr->lexeme;ptr++)
132132
{
133133
if (searchstoplist(&(d->stoplist),ptr->lexeme))
134134
{
135135
pfree(ptr->lexeme);
136136
ptr->lexeme=NULL;
137-
ptr++;
138137
}
139138
else
140139
{
141-
memcpy(cptr,ptr,sizeof(TSLexeme));
140+
if (cptr!=ptr)
141+
memcpy(cptr,ptr,sizeof(TSLexeme));
142142
cptr++;
143-
ptr++;
144143
}
145144
}
146145
cptr->lexeme=NULL;

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp