mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-03-01 19:45:33 +08:00
Fix crash of to_tsvector() function on huge input: compareWORD()
function didn't return correct result for word position greate than limit. Per report from Stuart Bishop <stuart@stuartbishop.net>
This commit is contained in:
parent
46dcd202ef
commit
76e114a458
@ -582,7 +582,12 @@ compareWORD(const void *a, const void *b)
|
||||
((TSWORD *) b)->len);
|
||||
|
||||
if (res == 0)
|
||||
{
|
||||
if ( ((TSWORD *) a)->pos.pos == ((TSWORD *) b)->pos.pos )
|
||||
return 0;
|
||||
|
||||
return (((TSWORD *) a)->pos.pos > ((TSWORD *) b)->pos.pos) ? 1 : -1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return (((TSWORD *) a)->len > ((TSWORD *) b)->len) ? 1 : -1;
|
||||
@ -632,7 +637,8 @@ uniqueWORD(TSWORD * a, int4 l)
|
||||
else
|
||||
{
|
||||
pfree(ptr->word);
|
||||
if (res->pos.apos[0] < MAXNUMPOS - 1 && res->pos.apos[res->pos.apos[0]] != MAXENTRYPOS - 1)
|
||||
if (res->pos.apos[0] < MAXNUMPOS - 1 && res->pos.apos[res->pos.apos[0]] != MAXENTRYPOS - 1 &&
|
||||
res->pos.apos[res->pos.apos[0]] != LIMITPOS(ptr->pos.pos) )
|
||||
{
|
||||
if (res->pos.apos[0] + 1 >= res->alen)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user