Skip to content

Commit

Permalink
Avoid nil-dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
skx committed Apr 9, 2022
1 parent a9e356b commit 7ffd819
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ func (e *Interpreter) term() object.Object {
f1 := e.factor()

if f1 == nil {
return object.Error("term() - received a nil value from factor()")
return object.Error("term() - received a nil value from factor() - f1")
}

if f1.Type() == object.ERROR {
Expand Down Expand Up @@ -636,6 +636,10 @@ func (e *Interpreter) term() object.Object {
// get the second argument
f2 := e.factor()

if f2 == nil {
return object.Error("term() - received a nil value from factor() - f2")
}

if e.offset >= len(e.program) {
return object.Error("Hit end of program processing term()")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go test fuzz v1
[]byte("DIM A(0)00A=0%A[0 0 0]0")

0 comments on commit 7ffd819

Please sign in to comment.