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:
wm4 2014-11-21 05:17:19 +01:00
parent 9c456ab58f
commit 9df4e7c70e
1 changed files with 2 additions and 2 deletions

View File

@ -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;
}