internal/encoding/json: fix crash in parsing

Fuzzer-detected crash when parsing: {""

Change-Id: I019c667f48e6a1237858b5abf7d34f43593fb3b6
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/212357
Reviewed-by: Herbie Ong <herbie@google.com>
diff --git a/internal/encoding/json/decode.go b/internal/encoding/json/decode.go
index ae2ee9a..3e58d06 100644
--- a/internal/encoding/json/decode.go
+++ b/internal/encoding/json/decode.go
@@ -102,6 +102,9 @@
 		}
 		d.in = d.in[n:]
 		d.consume(0)
+		if len(d.in) == 0 {
+			return Value{}, d.newSyntaxError(`unexpected EOF, missing ":" after object name`)
+		}
 		if c := d.in[0]; c != ':' {
 			return Value{}, d.newSyntaxError(`unexpected character %v, missing ":" after object name`, string(c))
 		}
diff --git a/internal/encoding/json/decode_test.go b/internal/encoding/json/decode_test.go
index c29d508..c896a2e 100644
--- a/internal/encoding/json/decode_test.go
+++ b/internal/encoding/json/decode_test.go
@@ -873,6 +873,13 @@
 			},
 		},
 		{
+			input: `{""`,
+			want: []R{
+				{T: json.StartObject},
+				{E: `syntax error (line 1:4): unexpected EOF`},
+			},
+		},
+		{
 			input: `{"34":"89",}`,
 			want: []R{
 				{T: json.StartObject},