diff --git a/decode_interface.go b/decode_interface.go index 2138f68..840718e 100644 --- a/decode_interface.go +++ b/decode_interface.go @@ -218,6 +218,7 @@ func (d *interfaceDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer) (i switch buf[cursor] { case '\\': cursor++ + continue case '"': literal := buf[start:cursor] cursor++ diff --git a/decode_test.go b/decode_test.go index afea9ef..8836b36 100644 --- a/decode_test.go +++ b/decode_test.go @@ -226,6 +226,14 @@ func Test_Decoder(t *testing.T) { }) } +func TestIssue98(t *testing.T) { + data := "[\"\\" + var v interface{} + if err := json.Unmarshal([]byte(data), &v); err == nil { + t.Fatal("expected error") + } +} + func Test_Decoder_UseNumber(t *testing.T) { dec := json.NewDecoder(strings.NewReader(`{"a": 3.14}`)) dec.UseNumber()