diff mbox

Go patch committed: Don't crash on redefinition of unsafe

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

Commit Message

Ian Lance Taylor Feb. 22, 2011, 3:23 a.m. UTC
This patch to the Go frontend avoids a crash if the unsafe package is
imported when the identifier "unsafe" is already defined.  This wais
correctly reported as a redefinition error, but the compiler then
proceeded to crash.  This patch avoids the crash.  Bootstrapped and ran
Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 602adf49962d go/unsafe.cc
--- a/go/unsafe.cc	Mon Feb 21 19:15:47 2011 -0800
+++ b/go/unsafe.cc	Mon Feb 21 19:22:34 2011 -0800
@@ -24,6 +24,13 @@ 
 						is_local_name_exported,
 						"libgo_unsafe",
 						location, &add_to_globals);
+
+  if (package == NULL)
+    {
+      gcc_assert(saw_errors());
+      return;
+    }
+
   package->set_is_imported();
 
   Bindings* bindings = package->bindings();