vala r909 - in trunk: . vala



Author: juergbi
Date: Sat Jan 26 12:10:24 2008
New Revision: 909
URL: http://svn.gnome.org/viewvc/vala?rev=909&view=rev

Log:
2008-01-26  Juerg Billeter  <j bitron ch>

	* vala/parser.y: fix critical on parse error in lambda expression,
	  fixes bug 511887


Modified:
   trunk/ChangeLog
   trunk/vala/parser.y

Modified: trunk/vala/parser.y
==============================================================================
--- trunk/vala/parser.y	(original)
+++ trunk/vala/parser.y	Sat Jan 26 12:10:24 2008
@@ -1523,51 +1523,71 @@
 lambda_expression
 	: OPEN_PARENS opt_lambda_parameter_list CLOSE_PARENS LAMBDA expression
 	  {
-		ValaSourceReference *src = src(@4);
-		$$ = VALA_EXPRESSION (vala_code_context_create_lambda_expression (context, $5, src));
-		if ($2 != NULL) {
-			GList *l;
-			for (l = $2; l != NULL; l = l->next) {
-				vala_lambda_expression_add_parameter (VALA_LAMBDA_EXPRESSION ($$), l->data);
-				g_free (l->data);
+		if ($5 == NULL) {
+			// error in lambda expression
+			$$ = NULL;
+		} else {
+			ValaSourceReference *src = src(@4);
+			$$ = VALA_EXPRESSION (vala_code_context_create_lambda_expression (context, $5, src));
+			if ($2 != NULL) {
+				GList *l;
+				for (l = $2; l != NULL; l = l->next) {
+					vala_lambda_expression_add_parameter (VALA_LAMBDA_EXPRESSION ($$), l->data);
+					g_free (l->data);
+				}
+				g_list_free ($2);
 			}
-			g_list_free ($2);
+			g_object_unref ($5);
+			g_object_unref (src);
 		}
-		g_object_unref ($5);
-		g_object_unref (src);
 	  }
 	| identifier LAMBDA expression
 	  {
-		ValaSourceReference *src = src(@2);
-		$$ = VALA_EXPRESSION (vala_code_context_create_lambda_expression (context, $3, src));
-		g_object_unref ($3);
-		g_object_unref (src);
-		vala_lambda_expression_add_parameter (VALA_LAMBDA_EXPRESSION ($$), $1);
-		g_free ($1);
+		if ($3 == NULL) {
+			// error in lambda expression
+			$$ = NULL;
+		} else {
+			ValaSourceReference *src = src(@2);
+			$$ = VALA_EXPRESSION (vala_code_context_create_lambda_expression (context, $3, src));
+			g_object_unref ($3);
+			g_object_unref (src);
+			vala_lambda_expression_add_parameter (VALA_LAMBDA_EXPRESSION ($$), $1);
+			g_free ($1);
+		}
 	  }
 	| OPEN_PARENS opt_lambda_parameter_list CLOSE_PARENS LAMBDA block
 	  {
-		ValaSourceReference *src = src(@4);
-		$$ = VALA_EXPRESSION (vala_code_context_create_lambda_expression_with_statement_body (context, VALA_BLOCK ($5), src));
-		if ($2 != NULL) {
-			GList *l;
-			for (l = $2; l != NULL; l = l->next) {
-				vala_lambda_expression_add_parameter (VALA_LAMBDA_EXPRESSION ($$), l->data);
-				g_free (l->data);
+		if ($5 == NULL) {
+			// error in lambda block
+			$$ = NULL;
+		} else {
+			ValaSourceReference *src = src(@4);
+			$$ = VALA_EXPRESSION (vala_code_context_create_lambda_expression_with_statement_body (context, VALA_BLOCK ($5), src));
+			if ($2 != NULL) {
+				GList *l;
+				for (l = $2; l != NULL; l = l->next) {
+					vala_lambda_expression_add_parameter (VALA_LAMBDA_EXPRESSION ($$), l->data);
+					g_free (l->data);
+				}
+				g_list_free ($2);
 			}
-			g_list_free ($2);
+			g_object_unref ($5);
+			g_object_unref (src);
 		}
-		g_object_unref ($5);
-		g_object_unref (src);
 	  }
 	| identifier LAMBDA block
 	  {
-		ValaSourceReference *src = src(@2);
-		$$ = VALA_EXPRESSION (vala_code_context_create_lambda_expression_with_statement_body (context, VALA_BLOCK ($3), src));
-		g_object_unref ($3);
-		g_object_unref (src);
-		vala_lambda_expression_add_parameter (VALA_LAMBDA_EXPRESSION ($$), $1);
-		g_free ($1);
+		if ($3 == NULL) {
+			// error in lambda block
+			$$ = NULL;
+		} else {
+			ValaSourceReference *src = src(@2);
+			$$ = VALA_EXPRESSION (vala_code_context_create_lambda_expression_with_statement_body (context, VALA_BLOCK ($3), src));
+			g_object_unref ($3);
+			g_object_unref (src);
+			vala_lambda_expression_add_parameter (VALA_LAMBDA_EXPRESSION ($$), $1);
+			g_free ($1);
+		}
 	  }
 	;
 



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