Fixed an issue in the Pygments lexer, that could cause a segmentation fault, if the file doesn't end with a newline.

Sun, 24 Mar 2013 13:08:24 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 24 Mar 2013 13:08:24 +0100
changeset 2519
e245447026ad
parent 2517
495777476cc4
child 2521
ca91f5ee1b23

Fixed an issue in the Pygments lexer, that could cause a segmentation fault, if the file doesn't end with a newline.

QScintilla/Lexers/LexerPygments.py file | annotate | diff | comparison | revisions
--- a/QScintilla/Lexers/LexerPygments.py	Sat Mar 23 16:03:22 2013 +0100
+++ b/QScintilla/Lexers/LexerPygments.py	Sun Mar 24 13:08:24 2013 +0100
@@ -422,6 +422,7 @@
         @param end position of last character to be styled (integer)
         """
         text = self.editor.text()[:end + 1]
+        textLen = len(text.encode("utf-8"))
         self.__lexer = self.__guessLexer(text)
         
         cpos = 0
@@ -443,9 +444,11 @@
                 tlen = len(txt.encode('utf-8'))
                 if eolLen > 1:
                     tlen += txt.count('\n')
-                if tlen:
+                cpos += tlen
+                if tlen and cpos < textLen:
                     self.editor.setStyling(tlen, style)
-                cpos += tlen
+                else:
+                    break
             self.editor.startStyling(cpos, 0x3f)
     
     def isCommentStyle(self, style):

eric ide

mercurial