Avoid core dump on empty thesaurus dictionary.
Per report from Robert Gravsjö.
This commit is contained in:
parent
1962ec6829
commit
b382cbb044
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 */
|
/* Array to search lexeme by exact match */
|
||||||
TheLexeme *wrds;
|
TheLexeme *wrds;
|
||||||
int nwrds;
|
int nwrds; /* current number of words */
|
||||||
int ntwrds;
|
int ntwrds; /* allocated array length */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Storage of substituted result, n-th element is for n-th expression
|
* Storage of substituted result, n-th element is for n-th expression
|
||||||
@ -298,7 +298,6 @@ thesaurusRead(char *filename, DictThesaurus *d)
|
|||||||
static TheLexeme *
|
static TheLexeme *
|
||||||
addCompiledLexeme(TheLexeme *newwrds, int *nnw, int *tnm, TSLexeme *lexeme, LexemeInfo *src, uint16 tnvariant)
|
addCompiledLexeme(TheLexeme *newwrds, int *nnw, int *tnm, TSLexeme *lexeme, LexemeInfo *src, uint16 tnvariant)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (*nnw >= *tnm)
|
if (*nnw >= *tnm)
|
||||||
{
|
{
|
||||||
*tnm *= 2;
|
*tnm *= 2;
|
||||||
@ -453,7 +452,8 @@ compileTheLexeme(DictThesaurus *d)
|
|||||||
pfree(d->wrds[i].entries);
|
pfree(d->wrds[i].entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
pfree(d->wrds);
|
if (d->wrds)
|
||||||
|
pfree(d->wrds);
|
||||||
d->wrds = newwrds;
|
d->wrds = newwrds;
|
||||||
d->nwrds = nnw;
|
d->nwrds = nnw;
|
||||||
d->ntwrds = tnm;
|
d->ntwrds = tnm;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user