[vlc-commits] codec: spudec: handle region alloc failure

Francois Cartegnie git at videolan.org
Mon Jan 13 18:09:57 CET 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jan  3 14:49:36 2020 +0100| [cc0879c75aca03596b1b15d75d60c16b74ee959e] | committer: Francois Cartegnie

codec: spudec: handle region alloc failure

(cherry picked from commit 39f66918c0e7414ff4fd1bc754b27bc5e2fd1f40)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=cc0879c75aca03596b1b15d75d60c16b74ee959e
---

 modules/codec/spudec/parse.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/modules/codec/spudec/parse.c b/modules/codec/spudec/parse.c
index 01a3de0722..2bb836e88e 100644
--- a/modules/codec/spudec/parse.c
+++ b/modules/codec/spudec/parse.c
@@ -74,7 +74,7 @@ static int  ParseControlSeq( decoder_t *, mtime_t i_pts,
                              void(*pf_queue)(decoder_t *, subpicture_t *) );
 static int  ParseRLE       ( decoder_t *, subpicture_data_t *,
                              const spu_properties_t *, uint16_t * );
-static void Render         ( decoder_t *, subpicture_t *, const uint16_t *,
+static int  Render         ( decoder_t *, subpicture_t *, const uint16_t *,
                              const subpicture_data_t *, const spu_properties_t * );
 
 /*****************************************************************************
@@ -248,7 +248,13 @@ static void OutputPicture( decoder_t *p_dec,
              render_spu_data.pi_offset[0], render_spu_data.pi_offset[1] );
 #endif
 
-    Render( p_dec, p_spu, p_pixeldata, &render_spu_data, p_spu_properties );
+    if( Render( p_dec, p_spu, p_pixeldata, &render_spu_data, p_spu_properties ) )
+    {
+        subpicture_Delete( p_spu );
+        free( p_pixeldata );
+        return;
+    }
+
     free( p_pixeldata );
 
     if( p_spu_data->p_pxctli && p_spu )
@@ -829,7 +835,7 @@ static int ParseRLE( decoder_t *p_dec,
     return VLC_SUCCESS;
 }
 
-static void Render( decoder_t *p_dec, subpicture_t *p_spu,
+static int Render( decoder_t *p_dec, subpicture_t *p_spu,
                     const uint16_t *p_pixeldata,
                     const subpicture_data_t *p_spu_data,
                     const spu_properties_t *p_spu_properties )
@@ -864,7 +870,7 @@ static void Render( decoder_t *p_dec, subpicture_t *p_spu,
         fmt.p_palette = NULL;
         video_format_Clean( &fmt );
         msg_Err( p_dec, "cannot allocate SPU region" );
-        return;
+        return VLC_EGENERIC;
     }
 
     p_spu->p_region->i_x = p_spu_properties->i_x;
@@ -887,4 +893,6 @@ static void Render( decoder_t *p_dec, subpicture_t *p_spu,
 
     fmt.p_palette = NULL;
     video_format_Clean( &fmt );
+
+    return VLC_SUCCESS;
 }



More information about the vlc-commits mailing list