Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0b1ee9b

Browse files
committed
fix hlfinditem function. Thanks to "Stphane Bidoul" <stephane.bidoul@softwareag.com>.
The 'word' variable there is initialised from the prs->words array, but immediately after, that array may be reallocated, thus leaving word pointing to unallocated memory.
1 parent 22c0b1f commit 0b1ee9b

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

contrib/tsearch2/expected/tsearch2.out

+5-5
Original file line numberDiff line numberDiff line change
@@ -2056,11 +2056,11 @@ An hour of storm to place
20562056
The sculpture of these granite seams,
20572057
Upon a woman s face. E. J. Pratt (1882 1964)
20582058
', to_tsquery('granite&sea'));
2059-
headline
2060-
----------------------------------------------------------------------------------------------
2061-
<b>sea</b> an hour one night
2062-
An hour of storm to place
2063-
The sculpture of these <b>granite</b>
2059+
headline
2060+
--------------------------------------------------------------------------------------------------
2061+
<b>sea</b> a thousand years,
2062+
A thousand years to trace
2063+
The <b>granite</b> features of this cliff
20642064
(1 row)
20652065

20662066

contrib/tsearch2/ts_cfg.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,15 @@ hlfinditem(HLPRSTEXT * prs, QUERYTYPE * query, char *buf, int buflen)
360360
{
361361
int i;
362362
ITEM *item = GETQUERY(query);
363-
HLWORD *word = &(prs->words[prs->curwords - 1]);
363+
HLWORD *word;
364364

365365
while (prs->curwords + query->size >= prs->lenwords)
366366
{
367367
prs->lenwords *= 2;
368368
prs->words = (HLWORD *) repalloc((void *) prs->words, prs->lenwords * sizeof(HLWORD));
369369
}
370370

371+
word = &(prs->words[prs->curwords - 1]);
371372
for (i = 0; i < query->size; i++)
372373
{
373374
if (item->type == VAL && item->length == buflen && strncmp(GETOPERAND(query) + item->distance, buf, buflen) == 0)

0 commit comments

Comments
 (0)