Skip to content

Commit

Permalink
codec: fix decoding struct from array - counter should be incremented…
Browse files Browse the repository at this point in the history
… at end of loop (not beginning)
  • Loading branch information
ugorji committed Feb 9, 2023
1 parent 95fe2c0 commit 502b0b4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion codec/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2090,7 +2090,6 @@ func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid
x.linef("var %shl%s bool = %s >= 0", tpfx, i, lenvarname) // has length
var newbuf, nilbuf genBuf
for _, si := range tisfi {
x.linef("%sj%s++", tpfx, i)
x.linef("%sb%s = !z.DecContainerNext(%sj%s, %s, %shl%s)", tpfx, i, tpfx, i, lenvarname, tpfx, i)
x.linef("if %sb%s { z.DecReadArrayEnd(); %s }", tpfx, i, breakString)
x.line("z.DecReadArrayElem()")
Expand All @@ -2104,6 +2103,7 @@ func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid
if len(newbuf.buf) > 0 {
x.line("}")
}
x.linef("%sj%s++", tpfx, i)
}
// read remaining values and throw away.
x.linef("for %sj%s++; z.DecContainerNext(%sj%s, %s, %shl%s); %sj%s++ {",
Expand Down

0 comments on commit 502b0b4

Please sign in to comment.