[texworks] [patch] Fix for index out-of-bounds in TeXHighlighter

Jonathan Kew jfkthame at googlemail.com
Mon Apr 19 15:57:23 CEST 2010


Yes, you're right - that needs to be checked. Thanks.

I'll commit the patch later, I'm not at the right machine just now.

On 18 Apr 2010, at 23:09, Pat Gavlin wrote:

> Building from svn on Ubuntu 9.10, TeXworks kept crashing after
> attempting to open a file.  Traced it to TeXHighlighter::highlightIndex
> being initialized to -1, causing syntaxOptions().at(highlightIndex) in
> TeXHighlighter::getSyntaxMode() to fail.  The patch below fixes this
> with a quick check to make sure highlightIndex is at least 0.
> 
> --- src/TeXHighlighter.h        2010-04-18 16:50:54.000000000 -0500
> +++ src/TeXHighlighter-new.h    2010-04-18 16:52:26.000000000 -0500
> @@ -44,7 +44,7 @@ public:
>        void setSpellChecker(Hunhandle *h, QTextCodec *codec);
> 
>        QString getSyntaxMode() const {
> -               return highlightIndex < syntaxOptions().size() ?
> syntaxOptions().at(highlightIndex) : QString();
> +               return (highlightIndex >= 0 && highlightIndex <
> syntaxOptions().size()) ? syntaxOptions().at(highlightIndex) :
> QString();
>        }
> 
>        static QStringList syntaxOptions();
> 
> --
> Pat Gavlin
> pgavlin at gmail.com
> pgavli2 at uic.edu
> 



More information about the texworks mailing list