Fix crash bugs: remove impossible nil checks, add bounds check for strings.Fields
- mailManager guaranteed non-nil by constructor, removed defensive checks - Added bounds check for strings.Fields()[0] in slash command validation - Removed impossible nil check in processMailboxes()
This commit is contained in:
parent
c10a008f3d
commit
addcf0a978
|
|
@ -426,7 +426,11 @@ func (s *Session) Send(ctx context.Context, prompt string) (string, error) {
|
|||
// Check command support if applicable
|
||||
if strings.HasPrefix(prompt, "/") && s.commands != nil {
|
||||
if !s.commands.IsSupported(prompt) {
|
||||
cmd := strings.Fields(prompt)[0]
|
||||
fields := strings.Fields(prompt)
|
||||
cmd := "unknown"
|
||||
if len(fields) > 0 {
|
||||
cmd = fields[0]
|
||||
}
|
||||
s.mu.Unlock()
|
||||
return "", fmt.Errorf("slash command not supported by %s backend: %s\nTo use manually, middle-click Attach", s.backendName, cmd)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,10 +192,6 @@ func (m *Manager) mailProcessingLoop() {
|
|||
|
||||
// processMailboxes handles outbox delivery and inbox processing
|
||||
func (m *Manager) processMailboxes() {
|
||||
if m.mailManager == nil {
|
||||
return
|
||||
}
|
||||
|
||||
m.mu.RLock()
|
||||
sessions := make([]backend.Session, 0, len(m.sessions))
|
||||
for _, sess := range m.sessions {
|
||||
|
|
@ -258,7 +254,7 @@ func (m *Manager) processMailboxes() {
|
|||
}
|
||||
}
|
||||
|
||||
// GetMailManager returns the mailbox manager
|
||||
// GetMailManager returns the mailbox manager (guaranteed non-nil)
|
||||
func (m *Manager) GetMailManager() *mailbox.Manager {
|
||||
return m.mailManager
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue