[poppler] poppler/Stream.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Tue May 22 18:25:34 UTC 2018


 poppler/Stream.cc |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 31c3832b996acbf04ea833e304d7d21ac4533a57
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue May 22 20:25:18 2018 +0200

    LZWStream::getCode: Don't left shift negative values
    
    it's undefined behaviour

diff --git a/poppler/Stream.cc b/poppler/Stream.cc
index 4f075c12..b6bfd838 100644
--- a/poppler/Stream.cc
+++ b/poppler/Stream.cc
@@ -1445,7 +1445,9 @@ int LZWStream::getCode() {
   while (inputBits < nextBits) {
     if ((c = str->getChar()) == EOF)
       return EOF;
-    inputBuf = (inputBuf << 8) | (c & 0xff);
+    if (likely(inputBuf >= 0)) {
+        inputBuf = (inputBuf << 8) | (c & 0xff);
+    }
     inputBits += 8;
   }
   code = (inputBuf >> (inputBits - nextBits)) & ((1 << nextBits) - 1);


More information about the poppler mailing list