[gtk+/gtk-2-24] gdkcairo: Don't leak pixel data
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] gdkcairo: Don't leak pixel data
- Date: Fri, 20 Feb 2015 19:54:42 +0000 (UTC)
commit 79c05314c60bc1fc45f80f8a2c54b9e1d309f04b
Author: Benjamin Otte <otte redhat com>
Date: Fri Feb 20 20:49:14 2015 +0100
gdkcairo: Don't leak pixel data
If we fail to attach pixel data to a cairo surface, free it immediately.
We still want to cairo_set_source() the surface to popagate the error.
Spotted by Christian Boxdörfer
gdk/gdkcairo.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c
index 2ad77d1..a3baa54 100644
--- a/gdk/gdkcairo.c
+++ b/gdk/gdkcairo.c
@@ -202,6 +202,7 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
cairo_format_t format;
cairo_surface_t *surface;
static const cairo_user_data_key_t key;
+ cairo_status_t status;
int j;
if (n_channels == 3)
@@ -215,8 +216,13 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
format,
width, height, cairo_stride);
- cairo_surface_set_user_data (surface, &key,
- cairo_pixels, (cairo_destroy_func_t)g_free);
+ status = cairo_surface_set_user_data (surface, &key,
+ cairo_pixels, (cairo_destroy_func_t)g_free);
+ if (status != CAIRO_STATUS_SUCCESS)
+ {
+ g_free (cairo_pixels);
+ goto out;
+ }
for (j = height; j; j--)
{
@@ -274,6 +280,7 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
cairo_pixels += cairo_stride;
}
+out:
cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
cairo_surface_destroy (surface);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]