From 92708e68b817912bd6fd6814805017cc24a9875f Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 18 Oct 2018 17:25:55 +0200 Subject: [PATCH] Release the buffer only after we are done with it We may end up touching the buffer after we have release()'d it, which means it may have been recycled by the time we call resetReaderIndex(). Move the release() call to after the check so we do not end up releasing it prematurely. Change-Id: I43156dbe2e6c53a552a322e7b5ea27f8da3873c2 Signed-off-by: Robert Varga --- .../nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java index bab4a7be63..96e54942df 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java @@ -106,14 +106,14 @@ public final class AsyncSshHandlerWriter implements AutoCloseable { promise.setFailure(future.getException()); } - // Not needed anymore, release - byteBufMsg.release(); - //rescheduling message from queue after successfully sent if (wasPending) { byteBufMsg.resetReaderIndex(); pending.remove(); } + + // Not needed anymore, release + byteBufMsg.release(); } // Check pending queue and schedule next -- 2.36.6