Commit 51c8a115 authored by Kamil Kisiel's avatar Kamil Kisiel

Fix panic in loadString

parent e3ff867d
...@@ -498,6 +498,10 @@ func (d *Decoder) loadString() error { ...@@ -498,6 +498,10 @@ func (d *Decoder) loadString() error {
return err return err
} }
if len(line) < 2 {
return io.ErrUnexpectedEOF
}
var delim byte var delim byte
switch line[0] { switch line[0] {
case '\'': case '\'':
...@@ -508,7 +512,7 @@ func (d *Decoder) loadString() error { ...@@ -508,7 +512,7 @@ func (d *Decoder) loadString() error {
return fmt.Errorf("invalid string delimiter: %c", line[0]) return fmt.Errorf("invalid string delimiter: %c", line[0])
} }
if len(line) < 2 || line[len(line)-1] != delim { if line[len(line)-1] != delim {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
......
...@@ -259,6 +259,7 @@ func TestMemoOpCode(t *testing.T) { ...@@ -259,6 +259,7 @@ func TestMemoOpCode(t *testing.T) {
func TestFuzzCrashers(t *testing.T) { func TestFuzzCrashers(t *testing.T) {
crashers := []string{ crashers := []string{
"(dS''\n(lc\n\na2a2a22aasS''\na", "(dS''\n(lc\n\na2a2a22aasS''\na",
"S\n",
} }
for _, c := range crashers { for _, c := range crashers {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment