[texworks] [patch] Fix for index out-of-bounds in TeXHighlighter
Pat Gavlin
pgavlin at gmail.com
Mon Apr 19 00:09:35 CEST 2010
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