Avoid signed overflow in random.c.
authorMark H Weaver <mhw@netris.org>
Wed, 12 Mar 2014 00:15:27 +0000 (20:15 -0400)
committerMark H Weaver <mhw@netris.org>
Wed, 12 Mar 2014 01:39:08 +0000 (21:39 -0400)
* libguile/random.c (scm_i_mask32): Avoid signed overflow from shifting
  an unsigned char (promoted to signed int) 24 bits to the left.

libguile/random.c

index 18737aa..4051d1f 100644 (file)
@@ -255,7 +255,7 @@ scm_i_mask32 (scm_t_uint32 m)
             ? scm_masktab[m >> 8] << 8 | 0xff
             : (m < 0x1000000
                ? scm_masktab[m >> 16] << 16 | 0xffff
-               : scm_masktab[m >> 24] << 24 | 0xffffff)));
+               : ((scm_t_uint32) scm_masktab[m >> 24]) << 24 | 0xffffff)));
 }
 
 scm_t_uint32