From a68a8004b5ab0e2744a204fdaa6a465f00961244 Mon Sep 17 00:00:00 2001 From: alanbur Date: Tue, 8 Aug 2017 11:56:36 +0100 Subject: PROTBUF-3394 Potential SIGBUS with UnsafeUtil.getLong --- java/core/src/main/java/com/google/protobuf/Utf8.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java') diff --git a/java/core/src/main/java/com/google/protobuf/Utf8.java b/java/core/src/main/java/com/google/protobuf/Utf8.java index be7b746e..d98e914d 100644 --- a/java/core/src/main/java/com/google/protobuf/Utf8.java +++ b/java/core/src/main/java/com/google/protobuf/Utf8.java @@ -1362,7 +1362,7 @@ final class Utf8 { // Read bytes until 8-byte aligned so that we can read longs in the loop below. // We do this by ANDing the address with 7 to determine the number of bytes that need to // be read before we're 8-byte aligned. - final int unaligned = (int) address & 7; + final int unaligned = 8 - ((int) address & 7); for (int j = unaligned; j > 0; j--) { if (UnsafeUtil.getByte(address++) < 0) { return unaligned - j; -- cgit v1.2.3