From b939bc8d681d6e74a0b23f0a28edea25d012edf8 Mon Sep 17 00:00:00 2001 From: Yaz Saito Date: Tue, 21 Jul 2020 23:35:43 -0700 Subject: [PATCH] Fix encoding of a large composite data type If encoding a field caused a buffer reallocation, the its length would be written to a wrong place. --- composite_type.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composite_type.go b/composite_type.go index 49ce70fa..cbe0a245 100644 --- a/composite_type.go +++ b/composite_type.go @@ -576,7 +576,7 @@ func (b *CompositeBinaryBuilder) AppendEncoder(oid uint32, field BinaryEncoder) return } if fieldBuf != nil { - binary.BigEndian.PutUint32(b.buf[lengthPos:], uint32(len(fieldBuf)-len(b.buf))) + binary.BigEndian.PutUint32(fieldBuf[lengthPos:], uint32(len(fieldBuf)-len(b.buf))) b.buf = fieldBuf }