summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Seipp <austin@well-typed.com>2014-04-23 03:41:44 -0500
committerAustin Seipp <austin@well-typed.com>2014-04-27 08:04:34 -0500
commit53c8e6e3b7fc8266c8843b7fa8f1e22d4413bc81 (patch)
tree4e1e5fde9433ba38d489715f2cae613a90938d26
parent8640d7b2a636702079878cd9cfb9b9349457c1e0 (diff)
downloadhaskell-53c8e6e3b7fc8266c8843b7fa8f1e22d4413bc81.tar.gz
rts: Fix possible int overflow in resize_nursery
n_capabilities is declared as unsigned int (32bit), and so multiplication is 32-bit before being stored in a 64bit integer (StgWord). Instead, cast n_capabilities to StgWord before multiplying. Discovered by Coverity. CID 43164. Signed-off-by: Austin Seipp <austin@well-typed.com> (cherry picked from commit 111b8454cc1b64da5b9816b89d79f44a8ae24355)
-rw-r--r--rts/sm/GC.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index 1ecbaf5ab1..d22a31eccb 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -1613,7 +1613,8 @@ resize_generations (void)
static void
resize_nursery (void)
{
- const StgWord min_nursery = RtsFlags.GcFlags.minAllocAreaSize * n_capabilities;
+ const StgWord min_nursery =
+ RtsFlags.GcFlags.minAllocAreaSize * (StgWord)n_capabilities;
if (RtsFlags.GcFlags.generations == 1)
{ // Two-space collector: