[vlc-commits] subpicture: YUVP subpicture formats should have a valid palette

Thomas Guillem git at videolan.org
Wed May 4 09:37:48 CEST 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue May  3 11:54:47 2016 +0200| [29c1c3fb7be01137bc6014864c84311bc97f872a] | committer: Thomas Guillem

subpicture: YUVP subpicture formats should have a valid palette

And return NULL if the palette allocation fails since most callers will assume
that the palette will be valid.

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

 src/misc/subpicture.c |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/misc/subpicture.c b/src/misc/subpicture.c
index 7f5d109..3ea95d8 100644
--- a/src/misc/subpicture.c
+++ b/src/misc/subpicture.c
@@ -206,12 +206,26 @@ subpicture_region_t *subpicture_region_New( const video_format_t *p_fmt )
     if( !p_region )
         return NULL;
 
-    video_format_Copy( &p_region->fmt, p_fmt );
-    if ( p_fmt->i_chroma != VLC_CODEC_YUVP )
+    if ( p_fmt->i_chroma == VLC_CODEC_YUVP )
     {
-        free( p_region->fmt.p_palette );
+        video_format_Copy( &p_region->fmt, p_fmt );
+        /* YUVP should have a palette */
+        if( p_region->fmt.p_palette == NULL )
+        {
+            p_region->fmt.p_palette = calloc( 1, sizeof(*p_region->fmt.p_palette) );
+            if( p_region->fmt.p_palette == NULL )
+            {
+                free( p_region );
+                return NULL;
+            }
+        }
+    }
+    else
+    {
+        p_region->fmt = *p_fmt;
         p_region->fmt.p_palette = NULL;
     }
+
     p_region->i_alpha = 0xff;
 
     if( p_fmt->i_chroma == VLC_CODEC_TEXT )



More information about the vlc-commits mailing list