[evince/gnome-3-2] [comics] Fix some memory leaks (bug #667258)



commit 15240624c27317ac355e54bb765f6570344ec011
Author: Juanjo MarÃn <juanj marin juntadeandalucia es>
Date:   Mon Jan 16 22:40:43 2012 +0100

    [comics] Fix some memory leaks (bug #667258)

 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 13750b2..1f19da4 100644
--- a/backend/comics/comics-document.c
+++ b/backend/comics/comics-document.c
@@ -624,15 +624,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 {
@@ -640,11 +638,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);
 	}
 }
 
@@ -661,7 +662,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;
@@ -700,10 +701,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 {
@@ -714,13 +715,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;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]