Mercurial > hg > octave-jordi
changeset 17194:aada14bf74ed
randmtzig.c: prevent left-shift of a 1 into sign bit in oct_init_by_entropy().
* randmtzig.c: in expression "word[0] + ... + (word[3]<<24)", cast the latter
to uint32_t before shifting, preventing (C99) undefined behavior.
author | Philipp Kutin <philipp.kutin@gmail.com> |
---|---|
date | Wed, 07 Aug 2013 12:54:30 +0200 |
parents | af2051e363ea |
children | 2899d110c178 |
files | liboctave/numeric/randmtzig.c |
diffstat | 1 files changed, 1 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/numeric/randmtzig.c +++ b/liboctave/numeric/randmtzig.c @@ -268,7 +268,7 @@ unsigned char word[4]; if (fread (word, 4, 1, urandom) != 1) break; - entropy[n++] = word[0]+(word[1]<<8)+(word[2]<<16)+(word[3]<<24); + entropy[n++] = word[0]+(word[1]<<8)+(word[2]<<16)+((uint32_t)word[3]<<24); } fclose (urandom); }