api: fix crash in rtspsessions/list and /rtspsessions/get (#5030) (#5031)

sometimes sessions have an empty associated path, and this caused a
crash.
This commit is contained in:
Alessandro Ros
2025-09-25 10:57:03 +02:00
committed by GitHub
parent 6b57c5187b
commit d6e6954a12

View File

@@ -409,7 +409,13 @@ func (s *session) apiItem() *defs.APIRTSPSession {
return defs.APIRTSPSessionStateIdle
}
}(),
Path: s.rsession.Path()[1:],
Path: func() string {
pa := s.rsession.Path()
if len(pa) >= 1 {
return pa[1:]
}
return ""
}(),
Query: s.rsession.Query(),
Transport: func() *string {
transport := s.rsession.Transport()