[poppler] poppler/JPXStream.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Mar 3 09:27:22 UTC 2019


 poppler/JPXStream.cc |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 2e406d3de277545c61ef462aca5b9e7b984dc477
Author: Robert Niemi <robert.den.klurige at gmail.com>
Date:   Sat Mar 2 06:43:30 2019 +0100

    JPXStream: Replaces undefined left-shift operations.
    
    Left-shifting a negative signed int is undefined. Most compilers shifts the same
    way as unsigned ints, but it's better to be clear about it.

diff --git a/poppler/JPXStream.cc b/poppler/JPXStream.cc
index e66ebb3f..9209d3ed 100644
--- a/poppler/JPXStream.cc
+++ b/poppler/JPXStream.cc
@@ -2816,7 +2816,7 @@ void JPXStream::inverseTransform(JPXTileComp *tileComp) {
 	    if (shift2 > 0) {
 	      cover(94);
 	      if (val < 0) {
-		val = (val << shift2) - (1 << (shift2 - 1));
+		val = (((unsigned int)val) << shift2) - (1 << (shift2 - 1));
 	      } else {
 		val = (val << shift2) + (1 << (shift2 - 1));
 	      }
@@ -2828,7 +2828,7 @@ void JPXStream::inverseTransform(JPXTileComp *tileComp) {
 	      cover(96);
 	      if (tileComp->transform == 0) {
 		cover(97);
-		val &= -1 << fracBits;
+		val &= 0xFFFFFFFF << fracBits;
 	      }
 	    } else {
 	      cover(98);
@@ -2931,7 +2931,7 @@ void JPXStream::inverseTransformLevel(JPXTileComp *tileComp,
 	      if (shift2 > 0) {
 		cover(74);
 		if (val < 0) {
-		  val = (val << shift2) - (1 << (shift2 - 1));
+		  val = (((unsigned int)val) << shift2) - (1 << (shift2 - 1));
 		} else {
 		  val = (val << shift2) + (1 << (shift2 - 1));
 		}
@@ -2942,7 +2942,7 @@ void JPXStream::inverseTransformLevel(JPXTileComp *tileComp,
 	      if (qStyle == 0) {
 		cover(76);
 		if (tileComp->transform == 0) {
-		  val &= -1 << fracBits;
+		  val &= 0xFFFFFFFF << fracBits;
 		}
 	      } else {
 		cover(77);


More information about the poppler mailing list