From 02fd255a14233ff77fd1176bba2834dbce42d98e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 20 Oct 2009 08:03:43 -0700 Subject: bug162, over and over R=ken OCL=35919 CL=35919 --- src/pkg/runtime/slice.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/pkg/runtime/slice.c') diff --git a/src/pkg/runtime/slice.c b/src/pkg/runtime/slice.c index 040029e5ea..722802c004 100644 --- a/src/pkg/runtime/slice.c +++ b/src/pkg/runtime/slice.c @@ -100,6 +100,13 @@ runtime·sliceslice(Slice old, uint32 lb, uint32 hb, uint32 width, Slice ret) void runtime·slicearray(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Slice ret) { + if(nel > 0 && old == nil) { + // crash if old == nil. + // could give a better message + // but this is consistent with all the in-line checks + // that the compiler inserts for other uses. + *old = 0; + } if(hb > nel || lb > hb) { if(debug) { @@ -146,6 +153,13 @@ runtime·slicearray(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, S void runtime·arraytoslice(byte* old, uint32 nel, Slice ret) { + if(nel > 0 && old == nil) { + // crash if old == nil. + // could give a better message + // but this is consistent with all the in-line checks + // that the compiler inserts for other uses. + *old = 0; + } // new dope to old array ret.len = nel; -- cgit v1.3-5-g9baa