[vlc-devel] commit: invmem: fix potential memleaks. ( Rémi Duraffort )

git version control git at videolan.org
Tue May 26 23:22:13 CEST 2009


vlc | branch: 1.0-bugfix | Rémi Duraffort <ivoire at videolan.org> | Tue May 26 23:16:30 2009 +0200| [f6c332fcd9e81eb4d6e13c471e5c4f18beb5aab7] | committer: Rémi Duraffort 

invmem: fix potential memleaks.

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

 modules/codec/invmem.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/codec/invmem.c b/modules/codec/invmem.c
index 396e80c..d672ecb 100644
--- a/modules/codec/invmem.c
+++ b/modules/codec/invmem.c
@@ -120,15 +120,16 @@ static int OpenDecoder( vlc_object_t *p_this )
     }
 
     /* Allocate the memory needed to store the decoder's structure */
-    if( ( p_dec->p_sys = p_sys =
-          (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
+    if( ( p_dec->p_sys = p_sys = malloc(sizeof(decoder_sys_t)) ) == NULL )
         return VLC_ENOMEM;
 
     // get parametrs
     p_sys->i_width = var_CreateGetInteger( p_this, "invmem-width" );
     p_sys->i_height = var_CreateGetInteger( p_this, "invmem-height" );
-    if (p_sys->i_width == 0 || p_sys->i_height == 0) {
+    if( p_sys->i_width == 0 || p_sys->i_height == 0 )
+    {
         msg_Err( p_dec, "--vmem-width and --vmem-height must be > 0" );
+        free( p_sys );
         return VLC_EGENERIC;
     }
 
@@ -147,6 +148,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     if( !p_sys->pf_lock || !p_sys->pf_unlock )
     {
         msg_Err( p_dec, "Invalid lock or unlock callbacks" );
+        free( p_sys );
         return VLC_EGENERIC;
     }
 




More information about the vlc-devel mailing list