]> git.sesse.net Git - vlc/commitdiff
invmem: fix potential memleaks.
authorRémi Duraffort <ivoire@videolan.org>
Tue, 26 May 2009 21:16:30 +0000 (23:16 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 29 May 2009 22:32:41 +0000 (00:32 +0200)
modules/codec/invmem.c

index 2990644f16584d2b5b0a6157e52bb36f124f5167..c63947cb83eb7e359ecb3dbbd1dc93a4cd9b629f 100644 (file)
@@ -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;
     }