diff options
| author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-03-07 13:13:33 +0200 |
|---|---|---|
| committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-03-07 13:43:28 +0200 |
| commit | ff9d757c67786b389f19abc3187d158adda500d8 (patch) | |
| tree | 0058725721e0c44f037f0c675b8bded5ca9ab382 /src/backend | |
| parent | fb61ff85e16636e82fa6ad01f8e106b14b84844f (diff) | |
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.
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/tsearch/dict_ispell.c | 9 | ||||
| -rw-r--r-- | src/backend/utils/adt/tsvector.c | 3 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/tsearch/dict_ispell.c b/src/backend/tsearch/dict_ispell.c index b6959e90e30..1cda70d2c43 100644 --- a/src/backend/tsearch/dict_ispell.c +++ b/src/backend/tsearch/dict_ispell.c @@ -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; diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c index 397e6c780bf..0dbbc9368bf 100644 --- a/src/backend/utils/adt/tsvector.c +++ b/src/backend/utils/adt/tsvector.c @@ -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) { |
