forked from mirror/go-json
Fix decoding of []byte type
This commit is contained in:
parent
048ba8296d
commit
8628848924
|
@ -65,10 +65,11 @@ func (d *bytesDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer) (int64
|
||||||
cursor = c
|
cursor = c
|
||||||
decodedLen := base64.StdEncoding.DecodedLen(len(bytes))
|
decodedLen := base64.StdEncoding.DecodedLen(len(bytes))
|
||||||
b := make([]byte, decodedLen)
|
b := make([]byte, decodedLen)
|
||||||
if _, err := base64.StdEncoding.Decode(b, bytes); err != nil {
|
n, err := base64.StdEncoding.Decode(b, bytes)
|
||||||
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
*(*[]byte)(p) = b
|
*(*[]byte)(p) = b[:n]
|
||||||
return cursor, nil
|
return cursor, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1864,6 +1864,7 @@ func TestUnmarshalMarshal(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
var numberTests = []struct {
|
var numberTests = []struct {
|
||||||
in string
|
in string
|
||||||
|
@ -1916,6 +1917,7 @@ func TestLargeByteSlice(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
type Xint struct {
|
type Xint struct {
|
||||||
X int
|
X int
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue