From 0cd127f0d86bda4a6f1645745af7b1cab84490f0 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Fri, 24 Jun 2016 19:52:10 +0200 Subject: comics: Fix some memory leaks http://bugzilla.gnome.org/show_bug.cgi?id=667258 taken from: https://git.gnome.org/browse/evince/commit/?id=d397c6d --- backend/comics/comics-document.c | 41 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'backend') diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c index e3e461ae..12ded35e 100644 --- a/backend/comics/comics-document.c +++ b/backend/comics/comics-document.c @@ -665,15 +665,13 @@ comics_document_get_page_size (EvDocument *document, gdk_pixbuf_loader_close (loader, NULL); } } - - if (gdk_pixbuf_loader_get_pixbuf (loader)) { - pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); + pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); + if (pixbuf) { if (width) *width = gdk_pixbuf_get_width (pixbuf); if (height) *height = gdk_pixbuf_get_height (pixbuf); } - g_spawn_close_pid (child_pid); g_object_unref (loader); } else { @@ -681,11 +679,14 @@ comics_document_get_page_size (EvDocument *document, (char *) comics_document->page_names->pdata[page->index], NULL); pixbuf = gdk_pixbuf_new_from_file (filename, NULL); + if (pixbuf) { + if (width) + *width = gdk_pixbuf_get_width (pixbuf); + if (height) + *height = gdk_pixbuf_get_height (pixbuf); + g_object_unref (pixbuf); + } g_free (filename); - if (width) - *width = gdk_pixbuf_get_width (pixbuf); - if (height) - *height = gdk_pixbuf_get_height (pixbuf); } } @@ -702,7 +703,7 @@ comics_document_render_pixbuf (EvDocument *document, EvRenderContext *rc) { GdkPixbufLoader *loader; - GdkPixbuf *rotated_pixbuf; + GdkPixbuf *rotated_pixbuf, *tmp_pixbuf; char **argv; guchar buf[4096]; gboolean success; @@ -741,10 +742,10 @@ comics_document_render_pixbuf (EvDocument *document, outpipe = -1; } } - - rotated_pixbuf = gdk_pixbuf_rotate_simple ( - gdk_pixbuf_loader_get_pixbuf (loader), - 360 - rc->rotation); + tmp_pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); + rotated_pixbuf = + gdk_pixbuf_rotate_simple (tmp_pixbuf, + 360 - rc->rotation); g_spawn_close_pid (child_pid); g_object_unref (loader); } else { @@ -755,13 +756,15 @@ comics_document_render_pixbuf (EvDocument *document, gdk_pixbuf_get_file_info (filename, &width, &height); - rotated_pixbuf = - gdk_pixbuf_rotate_simple (gdk_pixbuf_new_from_file_at_size ( - filename, width * (rc->scale) + 0.5, - height * (rc->scale) + 0.5, NULL), - 360 - rc->rotation); + tmp_pixbuf = + gdk_pixbuf_new_from_file_at_size ( + filename, width * (rc->scale) + 0.5, + height * (rc->scale) + 0.5, NULL); + rotated_pixbuf = + gdk_pixbuf_rotate_simple (tmp_pixbuf, + 360 - rc->rotation); g_free (filename); - + g_object_unref (tmp_pixbuf); } return rotated_pixbuf; } -- cgit v1.2.1