Browse code

Prevent infinite loop on incomplete files.

Issue found and fixed by Björn <wolfbjoe>.

Fixes #21.

Jose Fonseca authored on 25/12/2015 11:15:25
Showing 1 changed files

  • xdot.py index 15cf80d..f5e6fe0 100755
... ...
@@ -950,6 +950,12 @@ class Parser:
950 950
 
951 951
     def skip(self, type):
952 952
         while self.lookahead.type != type:
953
+            if self.lookahead.type == EOF:
954
+                raise ParseError(
955
+                   msg = 'unexpected end of file',
956
+                   filename = self.lexer.filename,
957
+                   line = self.lookahead.line,
958
+                   col = self.lookahead.col)
953 959
             self.consume()
954 960
 
955 961
     def consume(self):