mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
stream: fix endian swapping
In addition to the messed-up expression, the endianness was also inverted. The code reads big endian by default. It "worked" by coincidence, but for little endian, codepoints outside of latin1 were broken. The broken expression was found by Coverity.
This commit is contained in:
@@ -861,8 +861,8 @@ static uint16_t stream_read_word_endian(stream_t *s, bool big_endian)
|
||||
{
|
||||
unsigned int y = stream_read_char(s);
|
||||
y = (y << 8) | stream_read_char(s);
|
||||
if (big_endian)
|
||||
y = (y >> 8) | ((y << 8) & 0xFF);
|
||||
if (!big_endian)
|
||||
y = ((y >> 8) & 0xFF) | (y << 8);
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user