This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Go patch committed: Don't crash if append arguments are erroneous


This patch to the Go frontend avoids a crash if the arguments to the
predeclared function append are erroneous.  It checks for errors before
assuming that the type of the first argument is a slice.  Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian

diff -r 52053821a01d go/expressions.cc
--- a/go/expressions.cc	Tue Jan 04 14:36:50 2011 -0800
+++ b/go/expressions.cc	Tue Jan 04 14:50:55 2011 -0800
@@ -7965,14 +7965,14 @@
 	Expression* arg1 = args->front();
 	Expression* arg2 = args->back();
 
-	Array_type* at = arg1->type()->array_type();
-	Type* element_type = at->element_type();
-
 	tree arg1_tree = arg1->get_tree(context);
 	tree arg2_tree = arg2->get_tree(context);
 	if (arg1_tree == error_mark_node || arg2_tree == error_mark_node)
 	  return error_mark_node;
 
+	Array_type* at = arg1->type()->array_type();
+	Type* element_type = at->element_type();
+
 	arg2_tree = Expression::convert_for_assignment(context, at,
 						       arg2->type(),
 						       arg2_tree,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]