Fix decoder

This commit is contained in:
Masaaki Goshima 2021-06-05 16:00:17 +09:00
parent cbda08a525
commit 5e281e340f
2 changed files with 5 additions and 0 deletions

View File

@ -39,6 +39,7 @@ func unmarshal(data []byte, v interface{}, optFuncs ...DecodeOptionFunc) error {
}
ctx := decoder.TakeRuntimeContext()
ctx.Buf = src
ctx.Option.FirstWin = false
for _, optFunc := range optFuncs {
optFunc(ctx.Option)
}
@ -67,6 +68,7 @@ func unmarshalNoEscape(data []byte, v interface{}, optFuncs ...DecodeOptionFunc)
ctx := decoder.TakeRuntimeContext()
ctx.Buf = src
ctx.Option.FirstWin = false
for _, optFunc := range optFuncs {
optFunc(ctx.Option)
}

View File

@ -58,8 +58,11 @@ func (d *wrappedStringDecoder) Decode(ctx *RuntimeContext, cursor, depth int64,
return c, nil
}
bytes = append(bytes, nul)
oldBuf := ctx.Buf
ctx.Buf = bytes
if _, err := d.dec.Decode(ctx, 0, depth, p); err != nil {
return 0, err
}
ctx.Buf = oldBuf
return c, nil
}