aboutsummaryrefslogtreecommitdiff
path: root/www/firefox/files/patch-bug1632456
blob: 7822ff438a6723cb9c632cd04e0187f6fde74484 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
commit 0aaf67da2681
Author: Martin Stransky <stransky@redhat.com>
Date:   Wed May 27 08:37:58 2020 +0000

    Bug 1632456 [Wayland] Release mVAAPIDeviceContext when FFmpegVideoDecoder::CreateVAAPIDeviceContext() fails, r=jya
    
    Differential Revision: https://phabricator.services.mozilla.com/D76745
---
 dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
index 889d1d1ed5b97..1bd144d7375f4 100644
--- dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -175,6 +175,10 @@ bool FFmpegVideoDecoder<LIBAV_VER>::CreateVAAPIDeviceContext() {
   if (!mVAAPIDeviceContext) {
     return false;
   }
+
+  auto releaseVAAPIcontext =
+      MakeScopeExit([&] { mLib->av_buffer_unref(&mVAAPIDeviceContext); });
+
   AVHWDeviceContext* hwctx = (AVHWDeviceContext*)mVAAPIDeviceContext->data;
   AVVAAPIDeviceContext* vactx = (AVVAAPIDeviceContext*)hwctx->hwctx;
 
@@ -195,12 +199,12 @@ bool FFmpegVideoDecoder<LIBAV_VER>::CreateVAAPIDeviceContext() {
   }
 
   vactx->display = mDisplay;
-
   if (mLib->av_hwdevice_ctx_init(mVAAPIDeviceContext) < 0) {
     return false;
   }
 
   mCodecContext->hw_device_ctx = mLib->av_buffer_ref(mVAAPIDeviceContext);
+  releaseVAAPIcontext.release();
   return true;
 }