diff --git a/pkg/analyzer/defer_only.go b/pkg/analyzer/defer_only.go index ca97ad2..701c7c6 100644 --- a/pkg/analyzer/defer_only.go +++ b/pkg/analyzer/defer_only.go @@ -292,6 +292,10 @@ func getAction(instr ssa.Instruction, targetTypes []any) action { return actionReturned } + if instr.Addr.Referrers() == nil { + return actionNoOp + } + if len(*instr.Addr.Referrers()) == 0 { return actionNoOp } @@ -378,6 +382,10 @@ func checkDeferred(pass *analysis.Pass, instrs *[]ssa.Instruction, targetTypes [ return } case *ssa.Store: + if instr.Addr.Referrers() == nil { + return + } + if len(*instr.Addr.Referrers()) == 0 { return }