From 14d6ff8df6d83c2646fd7ac7aca226ed3111b765 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 2 Oct 2013 23:49:39 +0000 Subject: runtime: Fix append of slice with elements of zero size. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203140 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgo/runtime/go-append.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libgo') diff --git a/libgo/runtime/go-append.c b/libgo/runtime/go-append.c index 12fe876cb95..8d5dee21616 100644 --- a/libgo/runtime/go-append.c +++ b/libgo/runtime/go-append.c @@ -24,24 +24,24 @@ __go_append (struct __go_open_array a, void *bvalues, uintptr_t bcount, uintptr_t element_size) { uintptr_t ucount; - int count; + intgo count; if (bvalues == NULL || bcount == 0) return a; ucount = (uintptr_t) a.__count + bcount; - count = (int) ucount; + count = (intgo) ucount; if ((uintptr_t) count != ucount || count <= a.__count) runtime_panicstring ("append: slice overflow"); if (count > a.__capacity) { - int m; + intgo m; void *n; m = a.__capacity; - if (m == 0) - m = (int) bcount; + if (m + m < count) + m = count; else { do @@ -54,7 +54,7 @@ __go_append (struct __go_open_array a, void *bvalues, uintptr_t bcount, while (m < count); } - if ((uintptr) m > MaxMem / element_size) + if (element_size > 0 && (uintptr) m > MaxMem / element_size) runtime_panicstring ("growslice: cap out of range"); n = __go_alloc (m * element_size); -- cgit v1.2.1