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.
This commit is contained in:
parent
9af83c7cd1
commit
a704418110
1 changed files with 3 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue