File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -96,14 +96,19 @@ func (m Model) updateForm(msg tea.Msg) (tea.Model, tea.Cmd) {
9696}
9797
9898func (m Model ) beginScan (vals formValues ) (tea.Model , tea.Cmd ) {
99+ // Create the context up front so cancel is always assigned to the model
100+ // before any early return. This satisfies static analysis tools that
101+ // require the cancellation function to be demonstrably reachable.
102+ ctx , cancel := context .WithCancel (context .Background ())
103+ m .cancel = cancel
104+
99105 entries , _ , err := wordlist .LoadWordlist (vals .wordlist )
100106 if err != nil {
107+ cancel () // explicitly cancel before returning on error
101108 m .form .err = "cannot read wordlist: " + err .Error ()
102109 return m , nil
103110 }
104111
105- ctx , cancel := context .WithCancel (context .Background ())
106- m .cancel = cancel
107112 m .state = stateScan
108113 m .scanView = newScanViewModel (m .width , m .height , vals .simulate )
109114
You can’t perform that action at this time.
0 commit comments