From a704418110f16a7636719150ff5378991ac9e88e Mon Sep 17 00:00:00 2001 From: Uriel Date: Mon, 3 Sep 2012 02:45:23 +0200 Subject: [PATCH] There is some kind of off-by-one bug here and we end up with nils in the slice. I'm not sure exactly what the error is, but this code seems to be ancient and predate the invention of append(), I replaced it with a call to append() and seems to work fine. Leaving the code commented out because I'm not satisified I understand it. --- decode.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/decode.go b/decode.go index 77764b2..4adabd0 100644 --- a/decode.go +++ b/decode.go @@ -66,6 +66,7 @@ func (j *decoder) Elem(i int) Builder { v = make([]interface{}, 0, 8) j.value = v } +/* XXX There is a bug in here somewhere, but append() works fine. lens := len(v) if cap(v) <= lens { news := make([]interface{}, 0, lens*2) @@ -73,6 +74,8 @@ func (j *decoder) Elem(i int) Builder { v = news } v = v[0 : lens+1] +*/ + v = append(v, nil) j.value = v return newDecoder(v, i) }