Commit 31c3832b authored by Albert Astals Cid's avatar Albert Astals Cid

LZWStream::getCode: Don't left shift negative values

it's undefined behaviour
parent 2c0a0b07
......@@ -1445,7 +1445,9 @@ int LZWStream::getCode() {
while (inputBits < nextBits) {
if ((c = str->getChar()) == EOF)
return EOF;
if (likely(inputBuf >= 0)) {
inputBuf = (inputBuf << 8) | (c & 0xff);
}
inputBits += 8;
}
code = (inputBuf >> (inputBits - nextBits)) & ((1 << nextBits) - 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment