diff --git a/parser.go b/parser.go index a53c2b7..829f89e 100644 --- a/parser.go +++ b/parser.go @@ -353,7 +353,13 @@ func (p *parser) parseInlineTable(b []byte) (ast.Reference, []byte, error) { var err error for len(b) > 0 { + previousB := b b = p.parseWhitespace(b) + + if len(b) == 0 { + return parent, nil, newDecodeError(previousB[:1], "inline table is incomplete") + } + if b[0] == '}' { break } diff --git a/unmarshaler_test.go b/unmarshaler_test.go index 25484c2..43d49a3 100644 --- a/unmarshaler_test.go +++ b/unmarshaler_test.go @@ -1734,6 +1734,12 @@ func TestIssue581(t *testing.T) { require.Error(t, err) } +func TestIssue586(t *testing.T) { + var v interface{} + err := toml.Unmarshal([]byte(`a={ `), &v) + require.Error(t, err) +} + //nolint:funlen func TestUnmarshalDecodeErrors(t *testing.T) { examples := []struct {