Skip to content

Commit 9088542

Browse files
committed
Avoid core dump on empty thesaurus dictionary.
Per report from Robert Gravsjö.
1 parent bb1e8be commit 9088542

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/backend/tsearch/dict_thesaurus.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/tsearch/dict_thesaurus.c,v 1.14 2009/07/16 06:33:44 petere Exp $
10+
* $PostgreSQL: pgsql/src/backend/tsearch/dict_thesaurus.c,v 1.15 2009/11/30 16:38:31 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -57,8 +57,8 @@ typedef struct
5757

5858
/* Array to search lexeme by exact match */
5959
TheLexeme *wrds;
60-
int nwrds;
61-
int ntwrds;
60+
int nwrds; /* current number of words */
61+
int ntwrds; /* allocated array length */
6262

6363
/*
6464
* Storage of substituted result, n-th element is for n-th expression
@@ -298,7 +298,6 @@ thesaurusRead(char *filename, DictThesaurus *d)
298298
static TheLexeme *
299299
addCompiledLexeme(TheLexeme *newwrds, int *nnw, int *tnm, TSLexeme *lexeme, LexemeInfo *src, uint16 tnvariant)
300300
{
301-
302301
if (*nnw >= *tnm)
303302
{
304303
*tnm *= 2;
@@ -453,7 +452,8 @@ compileTheLexeme(DictThesaurus *d)
453452
pfree(d->wrds[i].entries);
454453
}
455454

456-
pfree(d->wrds);
455+
if (d->wrds)
456+
pfree(d->wrds);
457457
d->wrds = newwrds;
458458
d->nwrds = nnw;
459459
d->ntwrds = tnm;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy