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

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

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 24 Mar 2013 13:08:24 +0100
branch
5_3_x
changeset 2520
d226e801d308
parent 2518
1697fb3ad2d6
child 2522
250b92d6f3f9

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

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