[vlc-devel] commit: Fix allocation of picture_t without full initialization ( David Flynn )

git version control git at videolan.org
Wed Nov 5 20:29:25 CET 2008


vlc | branch: master | David Flynn <davidf at rd.bbc.co.uk> | Tue Nov  4 23:51:51 2008 +0000| [fc22aeaca9bd16f94c4ed10f67a3ff1d8cc5d1a8] | committer: Laurent Aimar 

Fix allocation of picture_t without full initialization

NB, this highlights some reference counting strangeness.

Signed-off-by: David Flynn <davidf at rd.bbc.co.uk>
Signed-off-by: Laurent Aimar <fenrir at videolan.org>

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

 modules/stream_out/transcode.c |   27 ++++++++-------------------
 1 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/modules/stream_out/transcode.c b/modules/stream_out/transcode.c
index c2040ff..83c5196 100644
--- a/modules/stream_out/transcode.c
+++ b/modules/stream_out/transcode.c
@@ -2224,31 +2224,20 @@ static picture_t *video_new_buffer( vlc_object_t *p_this, picture_t **pp_ring,
         i = 0;
     }
 
-    p_pic = malloc( sizeof(picture_t) );
+    p_pic = picture_New( p_dec->fmt_out.video.i_chroma,
+                         p_dec->fmt_out.video.i_width,
+                         p_dec->fmt_out.video.i_height,
+                         p_dec->fmt_out.video.i_aspect );
     if( !p_pic ) return NULL;
     p_dec->fmt_out.video.i_chroma = p_dec->fmt_out.i_codec;
-    vout_AllocatePicture( VLC_OBJECT(p_dec), p_pic,
-                          p_dec->fmt_out.video.i_chroma,
-                          p_dec->fmt_out.video.i_width,
-                          p_dec->fmt_out.video.i_height,
-                          p_dec->fmt_out.video.i_aspect );
-
-    if( !p_pic->i_planes )
-    {
-        free( p_pic );
-        return NULL;
-    }
-
-    p_pic->pf_release = video_release_buffer;
-    p_pic->p_sys = malloc( sizeof(picture_sys_t) );
+    p_pic->p_sys = calloc( 1, sizeof(picture_sys_t) );
     if( !p_pic->p_sys )
     {
-        free( p_pic );
+        picture_Release( p_pic );
         return NULL;
     }
-
-    p_pic->p_sys->p_owner = p_this;
-    p_pic->i_status = RESERVED_PICTURE;
+    p_pic->pf_release = video_release_buffer;
+    p_pic->i_refcount = 0;
 
     pp_ring[i] = p_pic;
     return p_pic;




More information about the vlc-devel mailing list