Fix possible use of uninitialised value in ts_headline()
authorTeodor Sigaev
Fri, 8 Apr 2016 18:25:47 +0000 (21:25 +0300)
committerTeodor Sigaev
Fri, 8 Apr 2016 18:25:47 +0000 (21:25 +0300)
Found during investigation of failure of skink buildfarm member and its
valgrind report.

Backpatch to all supported branches

src/backend/tsearch/wparser_def.c

index d53f2e75c2ec0038b12622b509bfc88d93e1c0e8..cbf35e9e06ee771feaadfedb88aeb97f981e5c17 100644 (file)
@@ -2439,6 +2439,8 @@ mark_hl_words(HeadlineParsedText *prs, TSQuery query, int highlight,
            }
            else
            {                   /* shorter cover :((( */
+               if (i > q)
+                   i = q;
                for (; curlen > min_words; i--)
                {
                    if (!NONWORDTOKEN(prs->words[i].type))