diff options
| author | Russ Cox <rsc@golang.org> | 2009-10-20 08:03:43 -0700 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2009-10-20 08:03:43 -0700 |
| commit | 02fd255a14233ff77fd1176bba2834dbce42d98e (patch) | |
| tree | 02fb381e9fe005b81d3e55cdbad2d5703b28c29d /src/pkg/runtime | |
| parent | d6b64f273fa579a74dc50f4dd736cde037bcc179 (diff) | |
| download | go-02fd255a14233ff77fd1176bba2834dbce42d98e.tar.xz | |
bug162, over and over
R=ken
OCL=35919
CL=35919
Diffstat (limited to 'src/pkg/runtime')
| -rw-r--r-- | src/pkg/runtime/slice.c | 14 |
1 files changed, 14 insertions, 0 deletions
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; |
