]> git.sesse.net Git - mlt/commitdiff
mlt_playlist_init(): check return values from mlt_producer_init() and calloc()
authorMikko Rapeli <mikko.rapeli@iki.fi>
Wed, 25 Jul 2012 15:50:45 +0000 (17:50 +0200)
committerMikko Rapeli <mikko.rapeli@iki.fi>
Wed, 25 Jul 2012 22:17:56 +0000 (00:17 +0200)
Fixes Coverity CID 709327: Unchecked return value (CHECKED_RETURN)
Calling function "mlt_producer_init" without checking return value (as is done elsewhere 17 out of 20 times).
No check of the return value of "mlt_producer_init(producer, self)".
  73                mlt_producer_init( producer, self );

src/framework/mlt_playlist.c

index ee81b20a7b3ce6108361625af230832926119a10..92d23382f81af51e8ab2e4f1a6f49b0596f67b1a 100644 (file)
@@ -70,7 +70,7 @@ mlt_playlist mlt_playlist_init( )
                mlt_producer producer = &self->parent;
 
                // Construct the producer
-               mlt_producer_init( producer, self );
+               if ( mlt_producer_init( producer, self ) != 0 ) goto error1;
 
                // Override the producer get_frame
                producer->get_frame = producer_get_frame;
@@ -80,7 +80,7 @@ mlt_playlist mlt_playlist_init( )
                producer->close_object = self;
 
                // Initialise blank
-               mlt_producer_init( &self->blank, NULL );
+               if ( mlt_producer_init( &self->blank, NULL ) != 0 ) goto error1;
                mlt_properties_set( MLT_PRODUCER_PROPERTIES( &self->blank ), "mlt_service", "blank" );
                mlt_properties_set( MLT_PRODUCER_PROPERTIES( &self->blank ), "resource", "blank" );
 
@@ -96,10 +96,17 @@ mlt_playlist mlt_playlist_init( )
                mlt_properties_set_position( MLT_PLAYLIST_PROPERTIES( self ), "length", 0 );
 
                self->size = 10;
-               self->list = malloc( self->size * sizeof( playlist_entry * ) );
+               self->list = calloc( self->size, sizeof( playlist_entry * ) );
+               if ( self->list == NULL ) goto error2;
+               
        }
 
        return self;
+error2:
+       free( self->list );
+error1:
+       free( self );
+       return NULL;
 }
 
 /** Construct a playlist with a profile.