aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/chan.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-09-28 21:25:20 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-09-28 21:25:20 +0000
commitddd06f537235203ce3e9f7a2a5e454410317995c (patch)
treec312f5f6a11f323dc9f8d70c8f1604219de561bb /libgo/runtime/chan.c
parente78410bf1198e3ce4a37678c991821359b0fde79 (diff)
downloadgcc-ddd06f537235203ce3e9f7a2a5e454410317995c.zip
gcc-ddd06f537235203ce3e9f7a2a5e454410317995c.tar.gz
gcc-ddd06f537235203ce3e9f7a2a5e454410317995c.tar.bz2
runtime: Better detection of memory allocation request overflow.
From-SVN: r191841
Diffstat (limited to 'libgo/runtime/chan.c')
-rw-r--r--libgo/runtime/chan.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libgo/runtime/chan.c b/libgo/runtime/chan.c
index c8ee10e..d0a1612 100644
--- a/libgo/runtime/chan.c
+++ b/libgo/runtime/chan.c
@@ -3,6 +3,8 @@
// license that can be found in the LICENSE file.
#include "runtime.h"
+#include "arch.h"
+#include "malloc.h"
#include "go-type.h"
#define NOSELGEN 1
@@ -88,7 +90,7 @@ runtime_makechan_c(ChanType *t, int64 hint)
elem = t->__element_type;
- if(hint < 0 || (int32)hint != hint || (elem->__size > 0 && (uintptr)hint > ((uintptr)-1) / elem->__size))
+ if(hint < 0 || (int32)hint != hint || (elem->__size > 0 && (uintptr)hint > MaxMem / elem->__size))
runtime_panicstring("makechan: size out of range");
n = sizeof(*c);