From d4baf3ccb7f7b6dd5476b82c480f30d3a2953399 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Sep 2010 23:28:12 -0400 Subject: [PATCH] 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 --- src/pkg/runtime/chan.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pkg/runtime/chan.c b/src/pkg/runtime/chan.c index 16c02e8e78..436f8b1401 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);