Go patch committed: Don't crash when copying function without closure

Submitted by Ian Taylor on Dec. 21, 2010, 10:56 p.m.

Details

Message ID mcripymloph.fsf@google.com
State New
Headers show

Commit Message

Ian Taylor Dec. 21, 2010, 10:56 p.m.
A bug in the Go frontend caused it to crash when copying a function
expression if the function had no closure.  I'm not sure this ever
happens for valid code, but it can happen for invalid code.  This patch
fixes it in the obvious way.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch hide | download patch | download mbox

diff -r 4e845d05aafc go/expressions.h
--- a/go/expressions.h	Tue Dec 21 14:29:32 2010 -0800
+++ b/go/expressions.h	Tue Dec 21 14:49:03 2010 -0800
@@ -1346,7 +1346,9 @@ 
   do_copy()
   {
     return Expression::make_func_reference(this->function_,
-					   this->closure_->copy(),
+					   (this->closure_ == NULL
+					    ? NULL
+					    : this->closure_->copy()),
 					   this->location());
   }