Allow double close of codecs (#364)

Video/AudioTrack.NewRTPReader() internally closes encoder on error.
It caused double free if user closes reader after error.
This commit is contained in:
Atsushi Watanabe
2021-11-21 22:57:50 +09:00
committed by GitHub
parent 1f313a9d61
commit a88c2daf89
12 changed files with 147 additions and 1 deletions
+5
View File
@@ -1,3 +1,4 @@
//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris
// +build dragonfly freebsd linux netbsd openbsd solaris
package vaapi
@@ -552,6 +553,10 @@ func (e *encoderVP8) Close() error {
e.mu.Lock()
defer e.mu.Unlock()
if e.closed {
return nil
}
C.vaDestroySurfaces(e.display, &e.surfs[0], C.int(len(e.surfs)))
C.vaDestroyContext(e.display, e.ctxID)
C.vaDestroyConfig(e.display, e.confID)