diff options
author | Andreas Cadhalpun <andreas.cadhalpun@googlemail.com> | 2016-01-13 00:56:39 +0100 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2016-01-15 13:47:11 +0100 |
commit | b06cb15b9d7928bf54b639c9f9f7658c2c38bfb9 (patch) | |
tree | 9494f620d9756d1b69c3729d4abf875f4ecd6732 /libavcodec/dca.c | |
parent | 9cdddb93bb33c58a5d42239326bc5eae0067366a (diff) | |
download | ffmpeg-b06cb15b9d7928bf54b639c9f9f7658c2c38bfb9.tar.gz |
dca: fix misaligned access in ff_dca_convert_bitstream
The function is used on unaligned buffers (such as those provided
by AVPacket), accessing them as uint16_t causes SIGBUS crashes on
architectures like SPARC.
This fixes ubsan runtime error: load of misaligned address for type
'const uint16_t', which requires 2 byte alignment
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavcodec/dca.c')
-rw-r--r-- | libavcodec/dca.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libavcodec/dca.c b/libavcodec/dca.c index ebe9fdb47c..c5daf077a9 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -37,8 +37,6 @@ int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, { uint32_t mrk; int i, tmp; - const uint16_t *ssrc = (const uint16_t *) src; - uint16_t *sdst = (uint16_t *) dst; PutBitContext pb; if ((unsigned) src_size > (unsigned) max_size) @@ -50,8 +48,11 @@ int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, memcpy(dst, src, src_size); return src_size; case DCA_SYNCWORD_CORE_LE: - for (i = 0; i < (src_size + 1) >> 1; i++) - *sdst++ = av_bswap16(*ssrc++); + for (i = 0; i < (src_size + 1) >> 1; i++) { + AV_WB16(dst, AV_RL16(src)); + src += 2; + dst += 2; + } return src_size; case DCA_SYNCWORD_CORE_14B_BE: case DCA_SYNCWORD_CORE_14B_LE: |