[vlc-devel] [PATCH v3 04/12] picture: allow NULL picture_resource_t in picture_NewFromResource

Steve Lhomme robux4 at ycbcr.xyz
Tue Aug 18 08:24:45 CEST 2020


---
 src/misc/picture.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/misc/picture.c b/src/misc/picture.c
index cc2173604a1..4ccd79d6d15 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -213,20 +213,23 @@ static bool picture_InitPrivate(const video_format_t *restrict p_fmt,
     atomic_init(&p_picture->refs, 1);
     priv->gc.opaque = NULL;
 
-    p_picture->p_sys = p_resource->p_sys;
-
-    if( p_resource->pf_destroy != NULL )
-        priv->gc.destroy = p_resource->pf_destroy;
-    else
+    if ( p_resource == NULL)
         priv->gc.destroy = picture_DestroyDummy;
+    else
+    {
+        p_picture->p_sys = p_resource->p_sys;
+
+        if( p_resource->pf_destroy != NULL )
+            priv->gc.destroy = p_resource->pf_destroy;
+        else
+            priv->gc.destroy = picture_DestroyDummy;
+    }
 
     return true;
 }
 
 picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_resource_t *p_resource )
 {
-    assert(p_resource != NULL);
-
     picture_priv_t *priv = malloc(sizeof(*priv));
     if (unlikely(priv == NULL))
         return NULL;
-- 
2.26.2



More information about the vlc-devel mailing list