ngl: Plug a memory leak
authorMatthias Clasen <mclasen@redhat.com>
Sun, 3 Oct 2021 06:16:56 +0000 (02:16 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 3 Oct 2021 06:33:01 +0000 (02:33 -0400)
When creating a GdkTexture from the texture
stored in the driver, we must free the GskNglTexture
struct.

gsk/ngl/gskngldriver.c

index 11974dfc238e9ee254900ad1bf2def85377a2714..3bf4ace07182cea85af3e6809bb9201ea6b7318b 100644 (file)
@@ -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);
 }