* Go patch committed: Don't crash on tuple init from bad channel
@ 2010-12-16 0:15 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2010-12-16 0:15 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 235 bytes --]
A tuple variable initialization from a channel expression, such as
v, ok := <-c
could crash if the RHS was erroneous. This patch fixes that.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.
Ian
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: foo.patch --]
[-- Type: text/x-diff, Size: 540 bytes --]
diff -r 8624179d2b0e go/gogo.cc
--- a/go/gogo.cc Wed Dec 15 15:38:16 2010 -0800
+++ b/go/gogo.cc Wed Dec 15 15:45:08 2010 -0800
@@ -3126,7 +3126,10 @@
else if (expr->receive_expression() != NULL)
{
Expression* channel = expr->receive_expression()->channel();
- return channel->type()->channel_type()->element_type();
+ Type* channel_type = channel->type();
+ if (channel_type->is_error_type())
+ return Type::make_error_type();
+ return channel_type->channel_type()->element_type();
}
else
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-12-15 23:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-16 0:15 Go patch committed: Don't crash on tuple init from bad channel Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).