]> git.sesse.net Git - vlc/commitdiff
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 7c136da9503741e8b0ba40fde70fb6b41ba6fe86..53b2c606f4598bdfeae301e0d99b61b3c5e2869f 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
+        }
 }
 
 /*****************************************************************************