From 4e6b3a5afc1c546edddcb1d8e09fb5a4721ab67c Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sun, 22 Sep 2013 19:35:10 +0100 Subject: [PATCH] Check for the end of the message --- msg.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/msg.go b/msg.go index 098f0a18..ad4d0a09 100644 --- a/msg.go +++ b/msg.go @@ -471,6 +471,11 @@ func packStructValue(val reflect.Value, msg []byte, off int, compression map[str // Length msg[off+2], msg[off+3] = packUint16(uint16(len(b))) off += 4 + if off+len(b) > lenmsg { + copy(msg[off:], b) + off = lenmsg + continue + } // Actual data copy(msg[off:off+len(b)], b) off += len(b)