]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix invalid memory access in scanner on unbalanced parentheses
authorJürg Billeter <j@bitron.ch>
Fri, 13 Nov 2009 21:20:14 +0000 (22:20 +0100)
committerJürg Billeter <j@bitron.ch>
Fri, 13 Nov 2009 21:20:14 +0000 (22:20 +0100)
Fixes bug 601789.

vala/valascanner.vala

index 109dca03f83eee773334c0747a632454fde89b6a..9a1d3eabcfe49a16ca3f226aed7e6eeec06385b5 100644 (file)
@@ -624,7 +624,9 @@ public class Vala.Scanner {
                        case '}':
                                type = TokenType.CLOSE_BRACE;
                                current++;
-                               state_stack.length--;
+                               if (state_stack.length > 0) {
+                                       state_stack.length--;
+                               }
                                break;
                        case '(':
                                type = TokenType.OPEN_PARENS;
@@ -634,7 +636,9 @@ public class Vala.Scanner {
                        case ')':
                                type = TokenType.CLOSE_PARENS;
                                current++;
-                               state_stack.length--;
+                               if (state_stack.length > 0) {
+                                       state_stack.length--;
+                               }
                                if (in_template ()) {
                                        type = TokenType.COMMA;
                                }
@@ -647,7 +651,9 @@ public class Vala.Scanner {
                        case ']':
                                type = TokenType.CLOSE_BRACKET;
                                current++;
-                               state_stack.length--;
+                               if (state_stack.length > 0) {
+                                       state_stack.length--;
+                               }
                                break;
                        case '.':
                                type = TokenType.DOT;