From: lilo_booter Date: Mon, 31 Jan 2005 14:58:52 +0000 (+0000) Subject: Memory leak fix X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=382bc6b99503a08abbfc9b32331e1cd35fd0205e;p=melted Memory leak fix git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@642 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/modules/gtk2/producer_pango.c b/src/modules/gtk2/producer_pango.c index b868063..b6f733c 100644 --- a/src/modules/gtk2/producer_pango.c +++ b/src/modules/gtk2/producer_pango.c @@ -444,7 +444,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form { // Clone our image uint8_t *copy = mlt_pool_alloc( size ); - if ( copy != NULL ) + if ( copy != NULL && image != NULL ) memcpy( copy, image, size ); // We're going to pass the copy on @@ -538,9 +538,13 @@ static void pango_draw_background( GdkPixbuf *pixbuf, rgba_color bg ) } } +static PangoFT2FontMap *fontmap = NULL; + static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const char *font, rgba_color fg, rgba_color bg, int pad, int align, int weight, int size ) { - PangoFT2FontMap *fontmap = (PangoFT2FontMap*) pango_ft2_font_map_new(); + if ( fontmap == NULL ) + fontmap = (PangoFT2FontMap*) pango_ft2_font_map_new(); + PangoContext *context = pango_ft2_font_map_create_context( fontmap ); PangoLayout *layout = pango_layout_new( context ); int w, h, x; @@ -607,9 +611,9 @@ static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const src += bitmap.pitch; } mlt_pool_release( bitmap.buffer ); + pango_font_description_free( desc ); g_object_unref( layout ); g_object_unref( context ); - g_object_unref( fontmap ); return pixbuf; }