Fix possible use of uninitialised value in ts_headline()
authorTeodor Sigaev <[email protected]>
Fri, 8 Apr 2016 18:26:12 +0000 (21:26 +0300)
committerTeodor Sigaev <[email protected]>
Fri, 8 Apr 2016 18:26:12 +0000 (21:26 +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 0648ec692e8426e8588dc6577fb37bfe9c6c13b6..edebc2be20d9f542eff74553d316080d1beaa680 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))