File: 0088-codec-avcodec-check-open-codec-return-value.patch

package info (click to toggle)
vlc 3.0.21-10
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 212,728 kB
  • sloc: ansic: 441,379; cpp: 110,628; objc: 36,394; sh: 6,947; makefile: 6,592; javascript: 4,902; xml: 1,611; asm: 1,355; yacc: 640; python: 555; lex: 88; perl: 77; sed: 16
file content (59 lines) | stat: -rw-r--r-- 2,024 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From: Zhao Zhili <quinkblack@foxmail.com>
Date: Fri, 11 Jun 2021 18:02:34 +0800
Subject: codec: avcodec: check open codec return value

(cherry picked from commit 21ab6be22e7c1831cebf023fd53bd7ffbfad22f6) (edited)
edited:
- on 3.0 DecodeBlock returns a picture_t, not an error code
---
 modules/codec/avcodec/audio.c |  7 ++++++-
 modules/codec/avcodec/video.c | 11 +++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index a3f67f7..e843675 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -309,7 +309,12 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
      && !avcodec_is_open( ctx ) )
     {
         InitDecoderConfig( p_dec, ctx );
-        OpenAudioCodec( p_dec );
+        if( OpenAudioCodec( p_dec ) < 0 )
+        {
+            if( pp_block != NULL && *pp_block != NULL )
+                block_Release( *pp_block );
+            return VLCDEC_ECRITICAL;
+        }
     }
 
     if( !avcodec_is_open( ctx ) )
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index c306e91..096a0b7 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1114,17 +1114,20 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
     bool eos_spotted = false;
 
 
-    block_t *p_block;
+    block_t *p_block = pp_block ? *pp_block : NULL;
     vlc_tick_t current_time;
 
     if( !p_context->extradata_size && p_dec->fmt_in.i_extra )
     {
         ffmpeg_InitCodec( p_dec );
-        if( !avcodec_is_open( p_context ) )
-            OpenVideoCodec( p_dec );
+        if( !avcodec_is_open( p_context ) && OpenVideoCodec(p_dec) < 0 )
+        {
+            if( p_block != NULL )
+                block_Release( p_block );
+            return NULL;
+        }
     }
 
-    p_block = pp_block ? *pp_block : NULL;
     if(!p_block && !(p_sys->p_codec->capabilities & AV_CODEC_CAP_DELAY) )
         return NULL;