[vala] Fix invalid memory access in scanner on unbalanced parentheses



commit 240ede2918df8c521346fe221cd6937873f67adf
Author: Jürg Billeter <j bitron ch>
Date:   Fri Nov 13 22:20:14 2009 +0100

    Fix invalid memory access in scanner on unbalanced parentheses
    
    Fixes bug 601789.

 vala/valascanner.vala |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/vala/valascanner.vala b/vala/valascanner.vala
index 109dca0..9a1d3ea 100644
--- a/vala/valascanner.vala
+++ b/vala/valascanner.vala
@@ -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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]