shithub: opus

Download patch

ref: a2ab52d24fb22a68f3e2704cc456fcf30048c05c
parent: d5f455ca1602f2000a1975278be7cef27805a38c
author: Gregory Maxwell <[email protected]>
date: Fri Sep 2 14:03:43 EDT 2011

Avoids signed overflow in ectest random number generation.

--- a/libcelt/tests/ectest.c
+++ b/libcelt/tests/ectest.c
@@ -108,8 +108,8 @@
     unsigned tell_bits;
     int       j;
     int zeros;
-    ft=rand()/((RAND_MAX>>(rand()%11))+1)+10;
-    sz=rand()/((RAND_MAX>>(rand()%9))+1);
+    ft=rand()/((RAND_MAX>>(rand()%11U))+1U)+10;
+    sz=rand()/((RAND_MAX>>(rand()%9U))+1U);
     data=(unsigned *)malloc(sz*sizeof(*data));
     tell=(unsigned *)malloc((sz+1)*sizeof(*tell));
     ec_enc_init(&enc,ptr,DATA_SIZE2);
@@ -170,7 +170,7 @@
     unsigned *tell;
     unsigned *enc_method;
     int       j;
-    sz=rand()/((RAND_MAX>>(rand()%9))+1);
+    sz=rand()/((RAND_MAX>>(rand()%9U))+1U);
     logp1=(unsigned *)malloc(sz*sizeof(*logp1));
     data=(unsigned *)malloc(sz*sizeof(*data));
     tell=(unsigned *)malloc((sz+1)*sizeof(*tell));