From 075471df41497e07891ad3e3944ee8e8e754199a Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Fri, 11 Apr 2014 10:37:11 -0700 Subject: gluegen: avoid bugs with sign-extension in readUInt16 Signed-off-by: Harvey Harrison --- src/java/com/jogamp/common/util/Bitstream.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/java/com/jogamp') diff --git a/src/java/com/jogamp/common/util/Bitstream.java b/src/java/com/jogamp/common/util/Bitstream.java index 55ba6de..393108b 100644 --- a/src/java/com/jogamp/common/util/Bitstream.java +++ b/src/java/com/jogamp/common/util/Bitstream.java @@ -1188,8 +1188,9 @@ public class Bitstream { */ public static final int readUInt16(final boolean bigEndian, final byte[] bytes, final int offset) throws IndexOutOfBoundsException { checkBounds(bytes, offset, 2); - final int b1 = bytes[offset]; - final int b2 = bytes[offset+1]; + // Make sure we clear any high bits that get set in sign-extension + final int b1 = bytes[offset] & 0xff; + final int b2 = bytes[offset+1] & 0xff; if( bigEndian ) { return b1 << 8 | b2; } else { -- cgit v1.2.3