[gthumb] cairo-io-png: fixed crash and memory leak when cancelling the operation



commit 419322e8fae1ca970ee0644d21b1e36c6333ca0d
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue May 3 13:29:08 2011 +0200

    cairo-io-png: fixed crash and memory leak when cancelling the operation

 extensions/cairo_io/cairo-io-png.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/extensions/cairo_io/cairo-io-png.c b/extensions/cairo_io/cairo-io-png.c
index 37dde77..84e2de9 100644
--- a/extensions/cairo_io/cairo-io-png.c
+++ b/extensions/cairo_io/cairo-io-png.c
@@ -40,6 +40,7 @@ _cairo_png_data_destroy (CairoPngData *cairo_png_data)
 {
 	png_destroy_read_struct (&cairo_png_data->png_ptr, &cairo_png_data->png_info_ptr, NULL);
 	g_object_unref (cairo_png_data->stream);
+	cairo_surface_destroy (cairo_png_data->surface);
 	g_free (cairo_png_data);
 }
 
@@ -60,7 +61,7 @@ static void
 gerror_warning_func (png_structp     png_ptr,
 		     png_const_charp message)
 {
-	/* we don't care about warnings */
+	/* void: we don't care about warnings */
 }
 
 
@@ -71,15 +72,18 @@ cairo_png_read_data_func (png_structp png_ptr,
 {
 	CairoPngData *cairo_png_data;
 	gssize        n;
+	GError       *error = NULL;
 
 	cairo_png_data = png_get_io_ptr (png_ptr);
 	n = g_input_stream_read (G_INPUT_STREAM (cairo_png_data->stream),
 				 buffer,
 				 size,
 				 cairo_png_data->cancellable,
-				 cairo_png_data->error);
-	if (n < 0)
-		png_error (png_ptr, NULL);
+				 &error);
+	if (n < 0) {
+		png_error (png_ptr, error->message);
+		g_error_free (error);
+	}
 }
 
 



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