From f7801f095a90ab9abc1f9971b87cf176232b367d Mon Sep 17 00:00:00 2001 From: Lucas Clemente Date: Fri, 5 Aug 2016 11:28:44 +0200 Subject: [PATCH] panic when trying to store a wrong-sized buffer in the buffer pool --- buffer_pool.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buffer_pool.go b/buffer_pool.go index 1c81308e..40ff3bfc 100644 --- a/buffer_pool.go +++ b/buffer_pool.go @@ -13,6 +13,10 @@ func getPacketBuffer() []byte { } func putPacketBuffer(buf []byte) { + if cap(buf) != int(protocol.MaxPacketSize) { + println(buf) + panic("putPacketBuffer called with packet of wrong size!") + } bufferPool.Put(buf[:0]) }