diff options
author | Reid Barton <rwbarton@gmail.com> | 2013-08-28 17:13:41 -0400 |
---|---|---|
committer | Austin Seipp <aseipp@pobox.com> | 2013-08-29 17:16:54 -0500 |
commit | 1247dff7b852d45dc5006ae8be33ac991cc76c74 (patch) | |
tree | d1b508a9c562be118ff9092d30e5339978efa867 /rts/posix | |
parent | 1ce65edbff90fc8103062a1f94258ecc0c682309 (diff) | |
download | haskell-1247dff7b852d45dc5006ae8be33ac991cc76c74.tar.gz |
Paranoid integer overflow check in osGetMBlocks
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'rts/posix')
-rw-r--r-- | rts/posix/OSMem.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c index cbc76f82d9..76b863e860 100644 --- a/rts/posix/OSMem.c +++ b/rts/posix/OSMem.c @@ -184,7 +184,8 @@ osGetMBlocks(nat n) // Compute size = MBLOCK_SIZE * (W_)n, // while testing for integer overflow. - // We assume that W_ is at least as large a type as nat. + if (n > (nat)((W_)-1)) + barf("osGetMBlocks: impossibly large MBlock count %d; nat larger than W_?", n); if ((W_)n > ((W_)-1) / MBLOCK_SIZE) { // We tried to allocate, say, 4 GB or more on a 32-bit system. errorBelch("out of memory (requested %d MBlocks)", n); |