]> git.sesse.net Git - vlc/commitdiff
flac: avoid overflow in conversion to signed integer
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 10 Jun 2014 19:45:57 +0000 (22:45 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 10 Jun 2014 19:45:57 +0000 (22:45 +0300)
modules/codec/flac.c

index 0d23842c79fd8d0776a2d878fbb050a044313858..b2ee916ab8ce3f6c6632e8eb58d0a1b8ff5dffc8 100644 (file)
@@ -134,7 +134,12 @@ static void Interleave( int32_t *p_out, const int32_t * const *pp_in,
 
     for( unsigned j = 0; j < i_samples; j++ )
         for( unsigned i = 0; i < i_nb_channels; i++ )
-            p_out[j * i_nb_channels + i] = ((uint32_t)pp_in[pi_index[i]][j]) << shift;
+        {
+            union { int32_t i; uint32_t u; } spl;
+
+            spl.u = ((uint32_t)pp_in[pi_index[i]][j]) << shift;
+            p_out[j * i_nb_channels + i] = spl.i;
+        }
 }
 
 /*****************************************************************************