2
0
mirror of synced 2025-02-24 06:38:14 +00:00

Fix buffer reuse bug and some formatting.

This commit is contained in:
Matt Joiner 2014-03-20 01:54:18 +11:00
parent d42799be2c
commit 7e2c384bd5

View File

@ -152,7 +152,9 @@ func (d *decoder) parse_string(v reflect.Value) {
Type: v.Type(), Type: v.Type(),
}) })
} }
v.Set(reflect.ValueOf(d.buf.Bytes())) sl := make([]byte, len(d.buf.Bytes()))
copy(sl, d.buf.Bytes())
v.Set(reflect.ValueOf(sl))
default: default:
panic(&UnmarshalTypeError{ panic(&UnmarshalTypeError{
Value: "string", Value: "string",
@ -335,7 +337,8 @@ func (d *decoder) read_one_value() bool {
switch b { switch b {
case 'd', 'l': case 'd', 'l':
// read until there is nothing to read // read until there is nothing to read
for d.read_one_value() {} for d.read_one_value() {
}
// consume 'e' as well // consume 'e' as well
b = d.read_byte() b = d.read_byte()
d.buf.WriteByte(b) d.buf.WriteByte(b)