Commit 301616f7 by Ian Lance Taylor

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

From-SVN: r203401
parent 15381741
...@@ -34,7 +34,10 @@ __go_make_slice2 (const struct __go_type_descriptor *td, uintptr_t len, ...@@ -34,7 +34,10 @@ __go_make_slice2 (const struct __go_type_descriptor *td, uintptr_t len,
std = (const struct __go_slice_type *) td; std = (const struct __go_slice_type *) td;
ilen = (intgo) len; 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"); runtime_panicstring ("makeslice: len out of range");
icap = (intgo) cap; icap = (intgo) cap;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment