]> git.sesse.net Git - vlc/blobdiff - modules/codec/schroedinger.c
Fix potential dereference of already free()d pointer
[vlc] / modules / codec / schroedinger.c
index 955ff7cb615c6e9499e1de42c62c7a917fd6150d..de41b73ac7c9816b6d77cc829c758764a2fd8d55 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;
@@ -246,6 +251,7 @@ static void SchroFrameFree( SchroFrame *frame, void *priv)
         return;
 
     if( p_pic->pf_release ) p_pic->pf_release( p_pic );
+    (void)frame;
 }
 
 /*****************************************************************************
@@ -315,6 +321,7 @@ static void SchroBufferFree( SchroBuffer *buf, void *priv )
         return;
 
     block_Release( p_block );
+    (void)buf;
 }
 
 /*****************************************************************************
@@ -357,7 +364,6 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     picture_t *p_pic;
     block_t *p_block;
     uint32_t u_pnum;
-    static int drop = 0;
 
     if( !pp_block ) return NULL;
 
@@ -463,11 +469,6 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             if( b_bail )
                 break;
         }
-
-        if( (i_bufused > 0) && (i_bufused < p_block->i_buffer) )
-            msg_Err( p_dec, "not submitted everything in p_buffer");
-
-
     } while( 0 );
 
     while( 1 )