server: fix crash that happens when a reader tries to setup a closed stream (https://github.com/aler9/rtsp-simple-server/issues/866)

This commit is contained in:
aler9
2022-06-14 15:32:16 +02:00
parent 7d0e8ed058
commit aa08f973dd
2 changed files with 44 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
package gortsplib
import (
"fmt"
"sync"
"time"
@@ -120,6 +121,10 @@ func (st *ServerStream) readerAdd(
st.mutex.Lock()
defer st.mutex.Unlock()
if st.readers == nil {
return fmt.Errorf("stream is closed")
}
if st.s == nil {
st.s = ss.s