Repository : ssh://[email protected]/ghc

On branch  : master
Link       : 
http://ghc.haskell.org/trac/ghc/changeset/1247dff7b852d45dc5006ae8be33ac991cc76c74/ghc

>---------------------------------------------------------------

commit 1247dff7b852d45dc5006ae8be33ac991cc76c74
Author: Reid Barton <[email protected]>
Date:   Wed Aug 28 17:13:41 2013 -0400

    Paranoid integer overflow check in osGetMBlocks
    
    Signed-off-by: Austin Seipp <[email protected]>


>---------------------------------------------------------------

1247dff7b852d45dc5006ae8be33ac991cc76c74
 rts/posix/OSMem.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index cbc76f8..76b863e 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);


_______________________________________________
ghc-commits mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/ghc-commits

Reply via email to