runtime: Report len out of range for large len when making slice.

From-SVN: r203401
This commit is contained in:
Ian Lance Taylor 2013-10-11 00:46:57 +00:00
parent 1538174146
commit 301616f7ff

View file

@ -34,7 +34,10 @@ __go_make_slice2 (const struct __go_type_descriptor *td, uintptr_t len,
std = (const struct __go_slice_type *) td;
ilen = (intgo) len;
if (ilen < 0 || (uintptr_t) ilen != len)
if (ilen < 0
|| (uintptr_t) ilen != len
|| (std->__element_type->__size > 0
&& len > MaxMem / std->__element_type->__size))
runtime_panicstring ("makeslice: len out of range");
icap = (intgo) cap;