1
0
mirror of https://github.com/golang/go synced 2024-11-21 22:14:41 -07:00

runtime: better panic for send to nil channel

*Much* better on NaCl, where memory faults are deadly.

R=r
CC=golang-dev
https://golang.org/cl/2249041
This commit is contained in:
Russ Cox 2010-09-19 23:28:12 -04:00
parent e769342614
commit d4baf3ccb7

View File

@ -403,6 +403,9 @@ void
int32 o; int32 o;
byte *ae; byte *ae;
if(c == nil)
panicstring("send to nil channel");
o = rnd(sizeof(c), c->elemalign); o = rnd(sizeof(c), c->elemalign);
ae = (byte*)&c + o; ae = (byte*)&c + o;
chansend(c, ae, nil); chansend(c, ae, nil);
@ -416,6 +419,9 @@ void
int32 o; int32 o;
byte *ae, *ap; byte *ae, *ap;
if(c == nil)
panicstring("send to nil channel");
o = rnd(sizeof(c), c->elemalign); o = rnd(sizeof(c), c->elemalign);
ae = (byte*)&c + o; ae = (byte*)&c + o;
o = rnd(o+c->elemsize, Structrnd); o = rnd(o+c->elemsize, Structrnd);