Commit 111b8454 authored by Austin Seipp's avatar Austin Seipp
Browse files

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: default avatarAustin Seipp <austin@well-typed.com>
parent 95da4097
......@@ -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:
......
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