summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2014-04-11 10:37:11 -0700
committerHarvey Harrison <[email protected]>2014-04-11 10:37:11 -0700
commit075471df41497e07891ad3e3944ee8e8e754199a (patch)
tree16ccacf027f97c77dc84efa10c83bfc78f32755e /src/java/com/jogamp
parent1fd1258aa4f12aea2c2d6aa445cb881fdbd84418 (diff)
gluegen: avoid bugs with sign-extension in readUInt16
Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src/java/com/jogamp')
-rw-r--r--src/java/com/jogamp/common/util/Bitstream.java5
1 files changed, 3 insertions, 2 deletions
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<T> {
*/
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 {