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:14:33 +0200 |
| commit | ad7b48ea08d6c33bae0a33c5f2a06272293c0f2f (patch) | |
| tree | 4983169d22f00d8bae6b6f8f0880cd93b4913fb6 /src/backend/tsearch | |
| parent | 2b8483d69d1be9700abae0dc7c48c5b7edb77498 (diff) | |
| download | postgresql-ad7b48ea08d6c33bae0a33c5f2a06272293c0f2f.tar.gz | |
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/tsearch')
| -rw-r--r-- | src/backend/tsearch/dict_ispell.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/backend/tsearch/dict_ispell.c b/src/backend/tsearch/dict_ispell.c index 64e2fbe487..4316c357e1 100644 --- a/src/backend/tsearch/dict_ispell.c +++ b/src/backend/tsearch/dict_ispell.c @@ -126,20 +126,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; |
