From ec62d942ea73d98ee2760746884779d7e0ccb6d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5ns=20Rullg=C3=A5rd?= Date: Wed, 1 Jul 2009 17:48:22 +0000 Subject: [PATCH] Fix potentially unaligned accesses in ff_copy_bits() A pointer should never be assigned a value which may have less than the required alignment of the target type. Compilers may assume pointer values have the required alignment, and emit normal load/store instructions. Unaligned pointers should use a character type or compiler-specific type modifiers. Originally committed as revision 19318 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/bitstream.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index efb5a3bfdb..3706f43124 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -78,7 +78,6 @@ void ff_put_string(PutBitContext * pbc, const char *s, int terminate_string) void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) { - const uint16_t *srcw= (const uint16_t*)src; int words= length>>4; int bits= length&15; int i; @@ -86,7 +85,7 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) if(length==0) return; if(CONFIG_SMALL || words < 16 || put_bits_count(pb)&7){ - for(i=0; i>(16-bits)); + put_bits(pb, bits, AV_RB16(src + 2*words)>>(16-bits)); } /* VLC decoding */