[vlc-commits] format: integer overflow

Rémi Denis-Courmont git at videolan.org
Wed Nov 19 16:17:22 CET 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Nov 19 17:16:05 2014 +0200| [8cbac79a706f013a1fb1f4d745d310d9197d173a] | committer: Rémi Denis-Courmont

format: integer overflow

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

 modules/audio_filter/converter/format.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/audio_filter/converter/format.c b/modules/audio_filter/converter/format.c
index bb55252..5b946cf 100644
--- a/modules/audio_filter/converter/format.c
+++ b/modules/audio_filter/converter/format.c
@@ -94,7 +94,7 @@ static block_t *U8toS16(filter_t *filter, block_t *bsrc)
     uint8_t *src = (uint8_t *)bsrc->p_buffer;
     int16_t *dst = (int16_t *)bdst->p_buffer;
     for (size_t i = bsrc->i_buffer; i--;)
-        *dst++ = ((*src++) - 128) << 8;
+        *dst++ = ((*src++) << 8) - 0x8000;
 out:
     block_Release(bsrc);
     VLC_UNUSED(filter);
@@ -128,7 +128,7 @@ static block_t *U8toS32(filter_t *filter, block_t *bsrc)
     uint8_t *src = (uint8_t *)bsrc->p_buffer;
     int32_t *dst = (int32_t *)bdst->p_buffer;
     for (size_t i = bsrc->i_buffer; i--;)
-        *dst++ = ((*src++) - 128) << 24;
+        *dst++ = ((*src++) << 24) - 0x80000000;
 out:
     block_Release(bsrc);
     VLC_UNUSED(filter);



More information about the vlc-commits mailing list