rtsp: fix memory leak when closing sessions (#4964) (#4678) (#4967)
Some checks are pending
code_lint / go (push) Waiting to run
code_lint / go_mod (push) Waiting to run
code_lint / docs (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run

This commit is contained in:
Alessandro Ros 2025-09-12 15:48:14 +02:00 committed by GitHub
parent 0c801564fd
commit e8b746b6d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -102,10 +102,9 @@ func (s *session) initialize() {
}
// Close closes a Session.
// this is not always called, so things that need to be released
// must go in onClose().
func (s *session) Close() {
s.discardedFrames.Stop()
s.decodeErrors.Stop()
s.packetsLost.Stop()
s.rsession.Close()
}
@ -136,6 +135,10 @@ func (s *session) onClose(err error) {
s.path = nil
s.stream = nil
s.discardedFrames.Stop()
s.decodeErrors.Stop()
s.packetsLost.Stop()
s.Log(logger.Info, "destroyed: %v", err)
}