diff options
author | wm4 <wm4@nowhere> | 2014-11-21 05:17:19 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-11-21 05:18:16 +0100 |
commit | 9df4e7c70e0c5e8e62ffcc30382614a7e300c79f (patch) | |
tree | 6e0c6cb2f61a9294c1a88dd7d0222a4c6720d8c8 /stream/stream.c | |
parent | 9c456ab58f7b298400a050aecdf49de4e035528d (diff) | |
download | mpv-9df4e7c70e0c5e8e62ffcc30382614a7e300c79f.tar.bz2 mpv-9df4e7c70e0c5e8e62ffcc30382614a7e300c79f.tar.xz |
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.
Diffstat (limited to 'stream/stream.c')
-rw-r--r-- | stream/stream.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/stream/stream.c b/stream/stream.c index 862d7fe252..2a851e82ec 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -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; } |