mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03: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
189f9a5bb2
commit
d77a9018fa
@ -604,7 +604,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;
|
||||
@ -654,7 +659,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…
x
Reference in New Issue
Block a user