Fix nil interface trap in GetByNumber
Map lookup returns typed nil *Session for missing keys, which wraps into CallSession interface as non-nil typed nil. Nil check silently passes, causing nil dereference.
This commit is contained in:
parent
53e877393d
commit
0ed9d18b27
1 changed files with 5 additions and 1 deletions
|
|
@ -357,7 +357,11 @@ func (s *Server) Unregister(number string) {
|
|||
func (s *Server) GetByNumber(number string) call.CallSession {
|
||||
s.sessionsMu.RLock()
|
||||
defer s.sessionsMu.RUnlock()
|
||||
return s.sessions[number]
|
||||
sess := s.sessions[number]
|
||||
if sess == nil {
|
||||
return nil
|
||||
}
|
||||
return sess
|
||||
}
|
||||
|
||||
func (s *Server) GetAll() []call.CallSession {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue