summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-09-19 23:28:12 -0400
committerRuss Cox <rsc@golang.org>2010-09-19 23:28:12 -0400
commit1f7125da2e7833808ad2e4f982eb4ded5cecaaf5 (patch)
treeed6302f0385366a3004dc48375a860d681fb3f7a
parentb867b3c4353c2ed3b4a78fb1b055688c1292eb02 (diff)
downloadgo-1f7125da2e7833808ad2e4f982eb4ded5cecaaf5.tar.gz
runtime: better panic for send to nil channel
*Much* better on NaCl, where memory faults are deadly. R=r CC=golang-dev http://codereview.appspot.com/2249041
-rw-r--r--src/pkg/runtime/chan.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/pkg/runtime/chan.c b/src/pkg/runtime/chan.c
index 16c02e8e7..436f8b140 100644
--- a/src/pkg/runtime/chan.c
+++ b/src/pkg/runtime/chan.c
@@ -403,6 +403,9 @@ void
int32 o;
byte *ae;
+ if(c == nil)
+ panicstring("send to nil channel");
+
o = rnd(sizeof(c), c->elemalign);
ae = (byte*)&c + o;
chansend(c, ae, nil);
@@ -416,6 +419,9 @@ void
int32 o;
byte *ae, *ap;
+ if(c == nil)
+ panicstring("send to nil channel");
+
o = rnd(sizeof(c), c->elemalign);
ae = (byte*)&c + o;
o = rnd(o+c->elemsize, Structrnd);