diff options
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/runtime/go-append.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libgo/runtime/go-append.c b/libgo/runtime/go-append.c index 12fe876..8d5dee2 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); |