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

login
register
mail settings
Submitter Ian Taylor
Date Dec. 21, 2010, 10:56 p.m.
Message ID <mcripymloph.fsf@google.com>
Download mbox | patch
Permalink /patch/76339/
State New
Headers show

Comments

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

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());
   }