]> git.sesse.net Git - vlc/commitdiff
Fix corner case memory leak
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sun, 29 Jun 2008 15:21:10 +0000 (18:21 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sun, 29 Jun 2008 15:21:10 +0000 (18:21 +0300)
modules/codec/schroedinger.c

index 955ff7cb615c6e9499e1de42c62c7a917fd6150d..46245f87247eb123f6db9e03f0ce176c6b5bf76d 100644 (file)
@@ -112,18 +112,23 @@ static int OpenDecoder( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
+    /* Allocate the memory needed to store the decoder's structure */
+    p_sys = malloc(sizeof(decoder_sys_t));
+    if( p_sys == NULL )
+        return VLC_ENOMEM;
+
     /* Initialise the schroedinger (and hence liboil libraries */
     /* This does no allocation and is safe to call */
     schro_init();
 
     /* Initialise the schroedinger decoder */
-    if( !(p_schro = schro_decoder_new()) ) return VLC_EGENERIC;
-
-    /* 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 )
-        return VLC_ENOMEM;
+    if( !(p_schro = schro_decoder_new()) )
+    {
+        free( p_sys );
+        return VLC_EGENERIC;
+    }
 
+    p_dec->p_sys = p_sys;
     p_sys->p_schro = p_schro;
     p_sys->p_format = NULL;
     p_sys->i_lastpts = -1;