Skip to content

Commit

Permalink
pkg/compiler: fix potential nil deref
Browse files Browse the repository at this point in the history
One one found on fuzzbuzz.io.
  • Loading branch information
dvyukov committed Mar 6, 2019
1 parent 05cf83b commit 967dc02
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/compiler/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,8 +870,9 @@ func (comp *compiler) replaceTypedef(ctx *checkCtx, t *ast.Type, flags checkFlag
t.Pos = pos0

// Remove base type if it's not needed in this context.
// If desc is nil, will return an error later when we typecheck the result.
desc := comp.getTypeDesc(t)
if flags&checkIsArg != 0 && desc.NeedBase {
if desc != nil && flags&checkIsArg != 0 && desc.NeedBase {
baseTypePos := len(t.Args) - 1
if t.Args[baseTypePos].Ident == "opt" {
baseTypePos--
Expand Down
2 changes: 2 additions & 0 deletions pkg/compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ func TestFuzz(t *testing.T) {
`t[
l t
]`,
`t()D[0]
type D[e]l`,
}
consts := map[string]uint64{"A": 1, "B": 2, "C": 3, "SYS_A": 4, "SYS_B": 5, "SYS_C": 6}
eh := func(pos ast.Pos, msg string) {
Expand Down

0 comments on commit 967dc02

Please sign in to comment.