[vlc-commits] flac: avoid overflow in conversion to signed integer

Rémi Denis-Courmont git at videolan.org
Tue Jun 10 21:46:26 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jun 10 22:45:57 2014 +0300| [0ba6f6e9e34565bca26ef7b9ecde7a365bcd2bcd] | committer: Rémi Denis-Courmont

flac: avoid overflow in conversion to signed integer

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0ba6f6e9e34565bca26ef7b9ecde7a365bcd2bcd
---

 modules/codec/flac.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/modules/codec/flac.c b/modules/codec/flac.c
index 0d23842..b2ee916 100644
--- a/modules/codec/flac.c
+++ b/modules/codec/flac.c
@@ -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;
+        }
 }
 
 /*****************************************************************************



More information about the vlc-commits mailing list