[MPlayer-dev-eng] Sign extension bug in stream_read_qword_le
Loren Merritt
lorenm at u.washington.edu
Sun Aug 19 10:28:51 CEST 2007
On Sun, 19 Aug 2007, Reimar Döffinger wrote:
> On Sun, Aug 19, 2007 at 12:30:41AM +0200, Sean Veers wrote:
>> --- mplayer-1.0-rc1svn20070812/stream/stream.h 2007-08-12
>> +++ mplayer-1.0-rc1svn20070812/stream/stream.h 2007-08-18
>> @@ -189,7 +189,7 @@ inline static uint64_t stream_read_qword_le
>> y = stream_read_char(s);
>> y|=stream_read_char(s)<<8;
>> y|=stream_read_char(s)<<16;
>> - y|=stream_read_char(s)<<24;
>> + y|=(uint32_t)stream_read_char(s)<<24;
>> y|=(uint64_t)stream_read_char(s)<<32;
>> y|=(uint64_t)stream_read_char(s)<<40;
>> y|=(uint64_t)stream_read_char(s)<<48;
>
> I'd propose replacing this by
> return stream_read_dword_le(s) | ((uint64_t)stream_read_dword_le(s) << 32);
>
> (untested though).
> Or the same with keeping y if you consider it more readable.
You need to keep y. Otherwise the compiler is allowed to evaluate the
arguments of | in any order.
--Loren Merritt
More information about the MPlayer-dev-eng
mailing list