Avoid memory leak when encoding the key

This commit is contained in:
Michael Nitschinger 2013-11-22 14:57:03 +01:00 committed by Norman Maurer
parent 132af3a485
commit 8b5f8de2ef

View File

@ -64,7 +64,12 @@ public abstract class BinaryMemcacheEncoder<M extends BinaryMemcacheMessage<H>,
return;
}
buf.writeBytes(Unpooled.copiedBuffer(key, CharsetUtil.UTF_8));
ByteBuf keyBuf = Unpooled.copiedBuffer(key, CharsetUtil.UTF_8);
try {
buf.writeBytes(keyBuf);
} finally {
keyBuf.release();
}
}
/**