]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Genie: Fix assertion failure on large rollback in parser
authorJamie McCracken <jamie.mccrack gmail com>
Mon, 24 May 2010 18:51:59 +0000 (14:51 -0400)
committerJamie McCracken <jamie.mccrack gmail com>
Mon, 24 May 2010 19:26:23 +0000 (15:26 -0400)
vala/valagenieparser.vala
vala/valageniescanner.vala

index a1305ea3d4eb0f3789117a4a86c938d0f48ad62d..18bf14601a6fb53e7172648725df6e5939fda28a 100644 (file)
@@ -200,7 +200,15 @@ public class Vala.Genie.Parser : CodeVisitor {
 
        void rollback (SourceLocation location) {
                while (tokens[index].begin.pos != location.pos) {
-                       prev ();
+                       index = (index - 1 + BUFFER_SIZE) % BUFFER_SIZE;
+                       size++;
+                       if (size > BUFFER_SIZE) {
+                               scanner.seek (location);
+                               size = 0;
+                               index = 0;
+
+                               next ();
+                       }
                }
        }
 
@@ -1012,6 +1020,11 @@ public class Vala.Genie.Parser : CodeVisitor {
                do {
                        if (!first) {
                                // array of arrays: new T[][42]
+                               
+                               if (size_specified) {
+                                       throw new ParseError.SYNTAX (get_error ("size of inner arrays must not be specified in array creation expression"));
+                               }
+                               
                                etype = new ArrayType (etype, size_specifier_list.size, etype.source_reference);
                        } else {
                                first = false;
index aacc3edfab989b5197b2c5a23da1a992a027546b..5c2bb6d524d25078c289aae3e36cf7ade51555df 100644 (file)
@@ -103,6 +103,15 @@ public class Vala.Genie.Scanner {
        bool is_ident_char (char c) {
                return (c.isalnum () || c == '_');
        }
+       
+       public void seek (SourceLocation location) {
+               current = location.pos;
+               line = location.line;
+               column = location.column;
+
+               conditional_stack = null;
+               state_stack = null;
+       }
 
        TokenType get_identifier_or_keyword (char* begin, int len) {
                switch (len) {