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

Commitc7a186e

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 parentff2e0e1 commitc7a186e

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

131-
ptr=cptr=res;
132-
while (ptr->lexeme)
131+
cptr=res;
132+
for (ptr=cptr;ptr->lexeme;ptr++)
133133
{
134134
if (searchstoplist(&(d->stoplist),ptr->lexeme))
135135
{
136136
pfree(ptr->lexeme);
137137
ptr->lexeme=NULL;
138-
ptr++;
139138
}
140139
else
141140
{
142-
memcpy(cptr,ptr,sizeof(TSLexeme));
141+
if (cptr!=ptr)
142+
memcpy(cptr,ptr,sizeof(TSLexeme));
143143
cptr++;
144-
ptr++;
145144
}
146145
}
147146
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