[vlc-devel] commit: Fix potential memleak and check malloc return value. ( Rémi Duraffort )

git version control git at videolan.org
Wed Aug 13 23:51:33 CEST 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Aug 13 23:53:27 2008 +0200| [8f6357b26a5f8d75f94ee83c960845bc6f4fbf6d] | committer: Rémi Duraffort 

Fix potential memleak and check malloc return value.

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

 modules/stream_out/transcode.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/modules/stream_out/transcode.c b/modules/stream_out/transcode.c
index 7f298e2..e9e84a1 100644
--- a/modules/stream_out/transcode.c
+++ b/modules/stream_out/transcode.c
@@ -1476,6 +1476,9 @@ static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_t *id )
     id->p_decoder->pf_picture_link    = video_link_picture_decoder;
     id->p_decoder->pf_picture_unlink  = video_unlink_picture_decoder;
     id->p_decoder->p_owner = malloc( sizeof(decoder_owner_sys_t) );
+    if( !id->p_decoder->p_owner )
+        return VLC_EGENERIC;
+
     for( i = 0; i < PICTURE_RING_SIZE; i++ )
         id->p_decoder->p_owner->pp_pics[i] = 0;
     id->p_decoder->p_owner->p_sys = p_sys;
@@ -1487,6 +1490,7 @@ static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_t *id )
     if( !id->p_decoder->p_module )
     {
         msg_Err( p_stream, "cannot find video decoder" );
+        free( id->p_decoder->p_owner );
         return VLC_EGENERIC;
     }
 
@@ -1525,6 +1529,7 @@ static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_t *id )
                  (char *)&p_sys->i_vcodec );
         module_Unneed( id->p_decoder, id->p_decoder->p_module );
         id->p_decoder->p_module = 0;
+        free( id->p_decoder->p_owner );
         return VLC_EGENERIC;
     }
 
@@ -1557,6 +1562,7 @@ static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_t *id )
             msg_Err( p_stream, "cannot spawn encoder thread" );
             module_Unneed( id->p_decoder, id->p_decoder->p_module );
             id->p_decoder->p_module = 0;
+            free( id->p_decoder->p_owner );
             return VLC_EGENERIC;
         }
     }




More information about the vlc-devel mailing list