Fix the NBT decoder panic if length less than 0
This commit is contained in:
@ -60,7 +60,7 @@ func TestUnmarshal_simple(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnmarshal_bittest(t *testing.T) {
|
||||
func TestUnmarshal_bitTest(t *testing.T) {
|
||||
// Generated by vscode-hexdump
|
||||
data := []byte{
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@ -306,3 +306,20 @@ func TestUnmarshal_ByteArray(t *testing.T) {
|
||||
}
|
||||
// t.Log(infValue)
|
||||
}
|
||||
|
||||
func TestUnmarshal_ErrorString(t *testing.T) {
|
||||
var data = []byte{
|
||||
0x08, 0x00, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0xFF, 0xFE,
|
||||
0x42, 0x61, 0x6e, 0x61, 0x6e, 0x72, 0x61, 0x6d, 0x61,
|
||||
}
|
||||
|
||||
//Unmarshal to string
|
||||
var Name string
|
||||
err := Unmarshal(data, &Name)
|
||||
|
||||
if err == nil {
|
||||
t.Error("should return a error if len < 0")
|
||||
}
|
||||
t.Log(err)
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user