mirror of https://git.ffmpeg.org/ffmpeg.git
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 <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
(cherry picked from commit 44ac13eed4
)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
This commit is contained in:
parent
f2fd5b9eb2
commit
873a0dfa26
|
@ -40,8 +40,6 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
|
||||||
{
|
{
|
||||||
uint32_t mrk;
|
uint32_t mrk;
|
||||||
int i, tmp;
|
int i, tmp;
|
||||||
const uint16_t *ssrc = (const uint16_t *) src;
|
|
||||||
uint16_t *sdst = (uint16_t *) dst;
|
|
||||||
PutBitContext pb;
|
PutBitContext pb;
|
||||||
|
|
||||||
if ((unsigned) src_size > (unsigned) max_size)
|
if ((unsigned) src_size > (unsigned) max_size)
|
||||||
|
@ -53,8 +51,11 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
|
||||||
memcpy(dst, src, src_size);
|
memcpy(dst, src, src_size);
|
||||||
return src_size;
|
return src_size;
|
||||||
case DCA_MARKER_RAW_LE:
|
case DCA_MARKER_RAW_LE:
|
||||||
for (i = 0; i < (src_size + 1) >> 1; i++)
|
for (i = 0; i < (src_size + 1) >> 1; i++) {
|
||||||
*sdst++ = av_bswap16(*ssrc++);
|
AV_WB16(dst, AV_RL16(src));
|
||||||
|
src += 2;
|
||||||
|
dst += 2;
|
||||||
|
}
|
||||||
return src_size;
|
return src_size;
|
||||||
case DCA_MARKER_14B_BE:
|
case DCA_MARKER_14B_BE:
|
||||||
case DCA_MARKER_14B_LE:
|
case DCA_MARKER_14B_LE:
|
||||||
|
|
Loading…
Reference in New Issue