[gtk/matthiasc/for-master: 2/2] ngl: Plug a memory leak




commit c93264868b0373b4cd08be5f0435182541d15741
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 3 02:16:56 2021 -0400

    ngl: Plug a memory leak
    
    When creating a GdkTexture from the texture
    stored in the driver, we must free the GskNglTexture
    struct.

 gsk/ngl/gskngldriver.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gsk/ngl/gskngldriver.c b/gsk/ngl/gskngldriver.c
index 11974dfc23..3bf4ace071 100644
--- a/gsk/ngl/gskngldriver.c
+++ b/gsk/ngl/gskngldriver.c
@@ -1335,6 +1335,7 @@ gsk_ngl_driver_create_gdk_texture (GskNglDriver *self,
 {
   GskNglTextureState *state;
   GskNglTexture *texture;
+  int width, height;
 
   g_return_val_if_fail (GSK_IS_NGL_DRIVER (self), NULL);
   g_return_val_if_fail (self->command_queue != NULL, NULL);
@@ -1352,10 +1353,16 @@ gsk_ngl_driver_create_gdk_texture (GskNglDriver *self,
 
   g_hash_table_steal (self->textures, GUINT_TO_POINTER (texture_id));
 
+  width = texture->width;
+  height = texture->height;
+
+  texture->texture_id = 0;
+  gsk_ngl_texture_free (texture);
+
   return gdk_gl_texture_new (self->command_queue->context,
                              texture_id,
-                             texture->width,
-                             texture->height,
+                             width,
+                             height,
                              create_texture_from_texture_destroy,
                              state);
 }


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