diff options
author | raveit65 <[email protected]> | 2016-06-24 19:52:10 +0200 |
---|---|---|
committer | monsta <[email protected]> | 2016-08-09 21:58:49 +0300 |
commit | 09504552544d2cd1642b24b6516af64c7eb32eba (patch) | |
tree | 07c441c2c8591d23189231068673c1e78bd738db | |
parent | c791ee64b8c0bf0c58f026a90df549bf00ecef2c (diff) | |
download | atril-09504552544d2cd1642b24b6516af64c7eb32eba.tar.bz2 atril-09504552544d2cd1642b24b6516af64c7eb32eba.tar.xz |
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
-rw-r--r-- | backend/comics/comics-document.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c index 2601d356..7ce740df 100644 --- a/backend/comics/comics-document.c +++ b/backend/comics/comics-document.c @@ -678,15 +678,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 { @@ -694,11 +692,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); } } @@ -715,7 +716,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; @@ -754,10 +755,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 { @@ -768,13 +769,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; } |