Reset proto before unmarshalling (#1222)

This commit is contained in:
Yongzheng Lai
2017-05-06 04:23:47 +08:00
committed by dfawley
parent 844f573616
commit 07f4e6bf4e

View File

@ -96,6 +96,7 @@ func (p protoCodec) Marshal(v interface{}) ([]byte, error) {
func (p protoCodec) Unmarshal(data []byte, v interface{}) error {
cb := protoBufferPool.Get().(*cachedProtoBuffer)
cb.SetBuf(data)
v.(proto.Message).Reset()
err := cb.Unmarshal(v.(proto.Message))
cb.SetBuf(nil)
protoBufferPool.Put(cb)