diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-11-30 16:38:40 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-11-30 16:38:40 +0000 |
commit | b382cbb0448e32a806e03976204f767a54ce36b5 (patch) | |
tree | d9c4b37b3ec0f643b46f215e0a47428463cb9d92 | |
parent | 1962ec68296271350346acc6bc1ce5e88bba8a64 (diff) | |
download | postgresql-b382cbb0448e32a806e03976204f767a54ce36b5.tar.gz |
Avoid core dump on empty thesaurus dictionary.
Per report from Robert Gravsjö.
-rw-r--r-- | src/backend/tsearch/dict_thesaurus.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/tsearch/dict_thesaurus.c b/src/backend/tsearch/dict_thesaurus.c index c7097fc666..7f3bab0635 100644 --- a/src/backend/tsearch/dict_thesaurus.c +++ b/src/backend/tsearch/dict_thesaurus.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tsearch/dict_thesaurus.c,v 1.13 2009/01/01 17:23:48 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/tsearch/dict_thesaurus.c,v 1.13.2.1 2009/11/30 16:38:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -57,8 +57,8 @@ typedef struct /* Array to search lexeme by exact match */ TheLexeme *wrds; - int nwrds; - int ntwrds; + int nwrds; /* current number of words */ + int ntwrds; /* allocated array length */ /* * Storage of substituted result, n-th element is for n-th expression @@ -298,7 +298,6 @@ thesaurusRead(char *filename, DictThesaurus *d) static TheLexeme * addCompiledLexeme(TheLexeme *newwrds, int *nnw, int *tnm, TSLexeme *lexeme, LexemeInfo *src, uint16 tnvariant) { - if (*nnw >= *tnm) { *tnm *= 2; @@ -453,7 +452,8 @@ compileTheLexeme(DictThesaurus *d) pfree(d->wrds[i].entries); } - pfree(d->wrds); + if (d->wrds) + pfree(d->wrds); d->wrds = newwrds; d->nwrds = nnw; d->ntwrds = tnm; |