vorbis (tremor): avoid overflow in conversion to signed integer
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 10 Jun 2014 19:46:09 +0000 (22:46 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 10 Jun 2014 19:46:09 +0000 (22:46 +0300)
modules/codec/vorbis.c

index 7c136da..53b2c60 100644 (file)
@@ -470,11 +470,16 @@ static void Interleave( INTERLEAVE_TYPE *p_out, const INTERLEAVE_TYPE **pp_in,
 {
     for( int j = 0; j < i_samples; j++ )
         for( int i = 0; i < i_nb_channels; i++ )
+        {
 #ifdef MODULE_NAME_IS_tremor
-            p_out[j * i_nb_channels + pi_chan_table[i]] = ((uint32_t)pp_in[i][j]) << 8;
+            union { int32_t i; uint32_t u;} spl;
+
+            spl.u = ((uint32_t)pp_in[i][j]) << 8;
+            p_out[j * i_nb_channels + pi_chan_table[i]] = spl.i;
 #else
             p_out[j * i_nb_channels + pi_chan_table[i]] = pp_in[i][j];
 #endif
+        }
 }
 
 /*****************************************************************************