]> git.sesse.net Git - mlt/blobdiff - src/modules/gtk2/producer_pixbuf.c
Merge pull request #6 from mcfrisk/coverity
[mlt] / src / modules / gtk2 / producer_pixbuf.c
index 0aa2a683d2f1c83b65c704eb2e5a1483c1a4dd5d..d1e15eaf2b562e74e4526e58ba2f80b60149e638 100644 (file)
@@ -73,7 +73,7 @@ static void producer_close( mlt_producer parent );
 
 mlt_producer producer_pixbuf_init( char *filename )
 {
-       producer_pixbuf self = calloc( sizeof( struct producer_pixbuf_s ), 1 );
+       producer_pixbuf self = calloc( 1, sizeof( struct producer_pixbuf_s ) );
        if ( self != NULL && mlt_producer_init( &self->parent, self ) == 0 )
        {
                mlt_producer producer = &self->parent;
@@ -438,6 +438,7 @@ static void refresh_image( producer_pixbuf self, mlt_frame frame, mlt_image_form
                int dst_stride = self->width * ( has_alpha ? 4 : 3 );
                int image_size = dst_stride * ( height + 1 );
                self->image = mlt_pool_alloc( image_size );
+               self->alpha = NULL;
                self->format = has_alpha ? mlt_image_rgb24a : mlt_image_rgb24;
 
                if ( src_stride != dst_stride )
@@ -485,13 +486,18 @@ static void refresh_image( producer_pixbuf self, mlt_frame frame, mlt_image_form
                        }
                }
 
+               // Update the cache
                mlt_cache_item_close( self->image_cache );
                mlt_service_cache_put( MLT_PRODUCER_SERVICE( producer ), "pixbuf.image", self->image, image_size, mlt_pool_release );
                self->image_cache = mlt_service_cache_get( MLT_PRODUCER_SERVICE( producer ), "pixbuf.image" );
                self->image_idx = current_idx;
                mlt_cache_item_close( self->alpha_cache );
-               mlt_service_cache_put( MLT_PRODUCER_SERVICE( producer ), "pixbuf.alpha", self->alpha, width * height, mlt_pool_release );
-               self->alpha_cache = mlt_service_cache_get( MLT_PRODUCER_SERVICE( producer ), "pixbuf.alpha" );
+               self->alpha_cache = NULL;
+               if ( self->alpha )
+               {
+                       mlt_service_cache_put( MLT_PRODUCER_SERVICE( producer ), "pixbuf.alpha", self->alpha, width * height, mlt_pool_release );
+                       self->alpha_cache = mlt_service_cache_get( MLT_PRODUCER_SERVICE( producer ), "pixbuf.alpha" );
+               }
 
                // Finished with pixbuf now
                g_object_unref( pixbuf );