]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: better panic for send to nil channel
authorRuss Cox <rsc@golang.org>
Mon, 20 Sep 2010 03:28:12 +0000 (23:28 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 20 Sep 2010 03:28:12 +0000 (23:28 -0400)
*Much* better on NaCl, where memory faults are deadly.

R=r
CC=golang-dev
https://golang.org/cl/2249041

src/pkg/runtime/chan.c

index 16c02e8e78b9e404060b7598bce5b73b10fef3e4..436f8b1401b6cac3bdf1220f13ff24b99784847d 100644 (file)
@@ -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);