From c161e526b9c426b147ae0c95473781263396ecd2 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Thu, 4 Feb 2016 22:18:03 +0100 Subject: [PATCH] [#4841] Fix segfault if UnpooledUnsafeHeapByteBuf.getShort(..) is used and UNALGINED access is not possible. Motivation: We missed to take the byte[] into account when try to access the bytes and so produce a segfault. Modifications: Correctly pass the byte[] in. Result: No more segfault. --- buffer/src/main/java/io/netty/buffer/UnsafeByteBufUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buffer/src/main/java/io/netty/buffer/UnsafeByteBufUtil.java b/buffer/src/main/java/io/netty/buffer/UnsafeByteBufUtil.java index c8b18d1e96..fe2d1dd285 100644 --- a/buffer/src/main/java/io/netty/buffer/UnsafeByteBufUtil.java +++ b/buffer/src/main/java/io/netty/buffer/UnsafeByteBufUtil.java @@ -152,7 +152,8 @@ final class UnsafeByteBufUtil { short v = PlatformDependent.getShort(array, index); return BIG_ENDIAN_NATIVE_ORDER ? v : Short.reverseBytes(v); } - return (short) (PlatformDependent.getByte(index) << 8 | PlatformDependent.getByte(index + 1) & 0xff); + return (short) (PlatformDependent.getByte(array, index) << 8 | + PlatformDependent.getByte(array, index + 1) & 0xff); } static int getUnsignedMedium(byte[] array, int index) {