Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitigate two potential nil pointer dereference issues. #5102

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/protocols/common/automaticscan/automaticscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ func (s *Service) getTagsUsingDetectionTemplates(input *contextargs.MetaInput) (
sg.Add()
go func(template *templates.Template) {
defer sg.Done()
if template.Executer == nil {
gologger.Verbose().Msgf("[%s] no executer available for template\n", aurora.BrightYellow(template.ID))
return
}
ctx := scan.NewScanContext(ctxArgs)
ctx.OnResult = func(event *output.InternalWrappedEvent) {
if event == nil {
Expand Down
13 changes: 7 additions & 6 deletions pkg/utils/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ const defaultMonitorIteration = 6

// NewStackMonitor returns a new stack monitor instance
func NewStackMonitor() *Agent {
return &Agent{}
return &Agent{
goroutineCount: 0,
currentIteration: 0,
}
}

// Callback when crash is detected and stack trace is saved to disk
Expand All @@ -57,10 +60,9 @@ func (s *Agent) Start(interval time.Duration) context.CancelFunc {
select {
case <-ctx.Done():
ticker.Stop()
return
case <-ticker.C:
s.monitorWorker(cancel)
default:
continue
}
}
}()
Expand Down Expand Up @@ -104,9 +106,8 @@ func (s *Agent) monitorWorker(cancel context.CancelFunc) {
}

s.lock.Lock()
callbacks := s.callbacks
s.lock.Unlock()
for _, callback := range callbacks {
defer s.lock.Unlock()
for _, callback := range s.callbacks {
if err := callback(dumpID); err != nil {
gologger.Error().Msgf("Stack monitor callback error: %s\n", err)
}
Expand Down
Loading