From fcd6becad90515db7c7cc3b3ae2aed481e826eed Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 8 Mar 2013 21:55:36 +0100 Subject: [PATCH] [#1136] Fix possible IllegalBufferAccessException when remove itself from the pipeline --- .../channel/DefaultChannelHandlerContext.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java index 07a2007ff7..e853ad1e01 100755 --- a/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java +++ b/transport/src/main/java/io/netty/channel/DefaultChannelHandlerContext.java @@ -949,14 +949,16 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements } catch (Throwable t) { notifyHandlerException(t); } finally { - if (handler instanceof ChannelInboundByteHandler && !pipeline.isInboundShutdown()) { - try { - ((ChannelInboundByteHandler) handler).discardInboundReadBytes(this); - } catch (Throwable t) { - notifyHandlerException(t); + if (!freed) { + if (handler instanceof ChannelInboundByteHandler && !pipeline.isInboundShutdown()) { + try { + ((ChannelInboundByteHandler) handler).discardInboundReadBytes(this); + } catch (Throwable t) { + notifyHandlerException(t); + } } + freeHandlerBuffersAfterRemoval(); } - freeHandlerBuffersAfterRemoval(); } } } else {