summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Cadhalpun <[email protected]>2016-01-13 00:52:58 +0100
committerAndreas Cadhalpun <[email protected]>2016-01-28 02:15:49 +0100
commit859a348e44d7f9f67c948a21aa3c5856de392ac5 (patch)
tree4ed9cfb893302a6d3091b5170f4f55e6437484cc
parent368a1803ff840c187f396ad014fce30190a3ffe3 (diff)
dca: fix misaligned access in avpriv_dca_convert_bitstream
src and dst are only 8-bit-aligned, so 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 Reviewed-by: Michael Niedermayer <[email protected]> Signed-off-by: Andreas Cadhalpun <[email protected]> (cherry picked from commit 44ac13eed49593f4f8efdb72ab0d5b48e05aa305) Signed-off-by: Andreas Cadhalpun <[email protected]>
-rw-r--r--libavcodec/dca.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavcodec/dca.c b/libavcodec/dca.c
index f9529760fc..45e6156919 100644
--- a/libavcodec/dca.c
+++ b/libavcodec/dca.c
@@ -41,8 +41,6 @@ int avpriv_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)
@@ -54,8 +52,11 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
memcpy(dst, src, src_size);
return src_size;
case DCA_MARKER_RAW_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_MARKER_14B_BE:
case DCA_MARKER_14B_LE: