summaryrefslogtreecommitdiff
path: root/libswresample/audioconvert.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-08 04:18:27 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-08 05:35:06 +0200
commit344f8d307ac766c812b4c33331235e8ac9120a9f (patch)
treeffaed1355d2f0611430aab097a61c4090c2803f0 /libswresample/audioconvert.c
parent9db9b209e3a32ecce93378a24fb931d7db35b1c2 (diff)
swresample/audioconvert: Fix undefined behavior (left shift of negative value)
Fixes: asan_heap-oob_4da4f3_8_asan_heap-oob_4da4f3_419_scene1a.mm Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample/audioconvert.c')
-rw-r--r--libswresample/audioconvert.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libswresample/audioconvert.c b/libswresample/audioconvert.c
index efdc9b5a89..58b0bf33e9 100644
--- a/libswresample/audioconvert.c
+++ b/libswresample/audioconvert.c
@@ -52,8 +52,8 @@ static void CONV_FUNC_NAME(ofmt, ifmt)(uint8_t *po, const uint8_t *pi, int is, i
//FIXME put things below under ifdefs so we do not waste space for cases no codec will need
CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_U8 , *(const uint8_t*)pi)
-CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)<<8)
-CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)<<24)
+CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80U)<<8)
+CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80U)<<24)
CONV_FUNC(AV_SAMPLE_FMT_FLT, float , AV_SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)*(1.0f/ (1<<7)))
CONV_FUNC(AV_SAMPLE_FMT_DBL, double , AV_SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)*(1.0 / (1<<7)))
CONV_FUNC(AV_SAMPLE_FMT_U8 , uint8_t, AV_SAMPLE_FMT_S16, (*(const int16_t*)pi>>8) + 0x80)