aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/slice.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/slice.go')
-rw-r--r--src/runtime/slice.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/runtime/slice.go b/src/runtime/slice.go
index 171087d7f6..f457f41429 100644
--- a/src/runtime/slice.go
+++ b/src/runtime/slice.go
@@ -53,7 +53,9 @@ func growslice(t *slicetype, old sliceStruct, n int64) sliceStruct {
et := t.elem
if et.size == 0 {
- return sliceStruct{old.array, old.len, cap}
+ // append should not create a slice with nil pointer but non-zero len.
+ // We assume that append doesn't need to preserve old.array in this case.
+ return sliceStruct{unsafe.Pointer(&zerobase), old.len, cap}
}
newcap := old.cap