This is an automated email from the ASF dual-hosted git repository.

johnnyv pushed a commit to branch 2.2.X
in repository https://gitbox.apache.org/repos/asf/mina.git


The following commit(s) were added to refs/heads/2.2.X by this push:
     new aaf12bd  Applies some code buffer free() checks from DIRMINA-1117
aaf12bd is described below

commit aaf12bd88e65d88cdbae8873735f2a778a066715
Author: Jonathan Valliere <john...@apache.org>
AuthorDate: Sat Jul 31 10:55:24 2021 -0400

    Applies some code buffer free() checks from DIRMINA-1117
---
 .../apache/mina/filter/codec/CumulativeProtocolDecoder.java    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git 
a/mina-core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
 
b/mina-core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
index fc3ace9..28126da 100644
--- 
a/mina-core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
+++ 
b/mina-core/src/main/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
@@ -165,6 +165,7 @@ public abstract class CumulativeProtocolDecoder extends 
ProtocolDecoderAdapter {
                 newBuf.put(buf);
                 newBuf.put(in);
                 newBuf.flip();
+                buf.free();
                 buf = newBuf;
 
                 // Update the session attribute.
@@ -233,9 +234,12 @@ public abstract class CumulativeProtocolDecoder extends 
ProtocolDecoderAdapter {
         removeSessionBuffer(session);
     }
 
-    private void removeSessionBuffer(IoSession session) {
-        session.removeAttribute(BUFFER);
-    }
+       private void removeSessionBuffer(IoSession session) {
+               IoBuffer buf = (IoBuffer) session.removeAttribute(BUFFER);
+               if (buf != null) {
+                       buf.free();
+               }
+       }
 
     private void storeRemainingInSession(IoBuffer buf, IoSession session) {
         final IoBuffer remainingBuf = 
IoBuffer.allocate(buf.capacity()).setAutoExpand(true);

Reply via email to