[vala/0.10] Genie: Fix out of bounds access in scanner



commit 6c9880c8bce66547e14997dc7650093e5f53d267
Author: Jürg Billeter <j bitron ch>
Date:   Sun Oct 24 13:24:01 2010 +0200

    Genie: Fix out of bounds access in scanner

 vala/valageniescanner.vala |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/vala/valageniescanner.vala b/vala/valageniescanner.vala
index a590dad..e1f945a 100644
--- a/vala/valageniescanner.vala
+++ b/vala/valageniescanner.vala
@@ -996,7 +996,9 @@ public class Vala.Genie.Scanner {
 			case '}':
 				type = TokenType.CLOSE_BRACE;
 				open_brace_count--;
-				state_stack.length--;
+				if (state_stack.length > 0) {
+					state_stack.length--;
+				}
 				current++;
 				break;
 			case '(':
@@ -1009,7 +1011,9 @@ public class Vala.Genie.Scanner {
 				type = TokenType.CLOSE_PARENS;
 				open_parens_count--;
 				current++;
-				state_stack.length--;
+				if (state_stack.length > 0) {
+					state_stack.length--;
+				}
 				if (in_template ()) {
 					type = TokenType.COMMA;
 				}
@@ -1021,7 +1025,9 @@ public class Vala.Genie.Scanner {
 				break;
 			case ']':
 				type = TokenType.CLOSE_BRACKET;
-				state_stack.length--;
+				if (state_stack.length > 0) {
+					state_stack.length--;
+				}
 				current++;
 				break;
 			case '.':



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