diff options
Diffstat (limited to 'libgo/runtime/go-new-channel.c')
-rw-r--r-- | libgo/runtime/go-new-channel.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libgo/runtime/go-new-channel.c b/libgo/runtime/go-new-channel.c index e440e87..0c6f391 100644 --- a/libgo/runtime/go-new-channel.c +++ b/libgo/runtime/go-new-channel.c @@ -13,17 +13,26 @@ #include "channel.h" struct __go_channel* -__go_new_channel (const struct __go_type_descriptor *element_type, +__go_new_channel (const struct __go_type_descriptor *channel_type, uintptr_t entries) { + const struct __go_channel_type *ctd; + const struct __go_type_descriptor *element_type; uintptr_t element_size; + int ientries; struct __go_channel* ret; size_t alloc_size; int i; + __go_assert (channel_type->__code == GO_CHAN); + ctd = (const struct __go_channel_type *) channel_type; + element_type = ctd->__element_type; + element_size = element_type->__size; - if ((uintptr_t) (int) entries != entries + ientries = (int) entries; + if (ientries < 0 + || (uintptr_t) ientries != entries || entries > (uintptr_t) -1 / element_size) __go_panic_msg ("chan size out of range"); |