[libadwaita] avatar: Fix memory leaks



commit 1d5340b93cfe4900c99e9be233eaa8aead50a514
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Tue Jul 20 17:28:41 2021 +0530

    avatar: Fix memory leaks

 src/adw-avatar.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/adw-avatar.c b/src/adw-avatar.c
index a72f5bf6..47755450 100644
--- a/src/adw-avatar.c
+++ b/src/adw-avatar.c
@@ -700,6 +700,7 @@ adw_avatar_draw_to_pixbuf (AdwAvatar *self,
 {
   GtkSnapshot *snapshot;
   g_autoptr (GskRenderNode) node = NULL;
+  GdkPixbuf *avatar;
   cairo_surface_t *surface;
   cairo_t *cr;
   graphene_rect_t bounds;
@@ -727,7 +728,11 @@ adw_avatar_draw_to_pixbuf (AdwAvatar *self,
 
   gsk_render_node_draw (node, cr);
 
-  return gdk_pixbuf_get_from_surface (surface, 0, 0,
-                                      bounds.size.width,
-                                      bounds.size.height);
+  avatar = gdk_pixbuf_get_from_surface (surface, 0, 0,
+                                        bounds.size.width,
+                                        bounds.size.height);
+  cairo_surface_destroy (surface);
+  cairo_destroy (cr);
+
+  return avatar;
 }


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