summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2016-06-24 19:52:10 +0200
committerraveit65 <[email protected]>2016-06-29 16:23:03 +0200
commit0cd127f0d86bda4a6f1645745af7b1cab84490f0 (patch)
tree5972dcce3fc859e01c8517b7404538ebe0569b34
parentb583933820718abeb0f09b38f08bdf53c6924340 (diff)
downloadatril-0cd127f0d86bda4a6f1645745af7b1cab84490f0.tar.bz2
atril-0cd127f0d86bda4a6f1645745af7b1cab84490f0.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.c41
1 files changed, 22 insertions, 19 deletions
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;
}