Fix signed integer overflow in random_r (bug 17343)

Paul Eggert eggert@cs.ucla.edu
Sat Mar 17 00:26:00 GMT 2018


Joseph Myers wrote:
>         int32_t val = state[0];
> -      val = ((state[0] * 1103515245) + 12345) & 0x7fffffff;
> +      val = ((state[0] * 1103515245U) + 12345U) & 0x7fffffff;

The first assignment to VAL (in the unchanged line) is unnecessary; I suggest 
coalescing the two lines.



More information about the Libc-alpha mailing list