From f6251c8256d8ce3fb6fb76df23e477caa15f627b Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Sat, 10 Mar 2018 01:25:17 -0800 Subject: [PATCH] IovArray.add(...) should check if buffer has memory address. Motivation: We currently not check if the buffer has a memory address and just assume this is the case if the nioBufferCount() == 1. Modifications: - Check hasMemoryAddress() before trying to access it. - Add unit case. Result: More correct and robust code. Related to [#7752]. --- .../src/main/java/io/netty/channel/unix/IovArray.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transport-native-unix-common/src/main/java/io/netty/channel/unix/IovArray.java b/transport-native-unix-common/src/main/java/io/netty/channel/unix/IovArray.java index 3e0946e255..151abe609a 100644 --- a/transport-native-unix-common/src/main/java/io/netty/channel/unix/IovArray.java +++ b/transport-native-unix-common/src/main/java/io/netty/channel/unix/IovArray.java @@ -91,7 +91,7 @@ public final class IovArray implements MessageProcessor { if (count == IOV_MAX) { // No more room! return false; - } else if (buf.nioBufferCount() == 1) { + } else if (buf.hasMemoryAddress() && buf.nioBufferCount() == 1) { final int len = buf.readableBytes(); return len == 0 || add(buf.memoryAddress(), buf.readerIndex(), len); } else {