[mutter/gnome-40] clutter/layer-paint-node: Handle failure to allocate offscreen



commit fe7feee0b131ef858dde17ca3cb8dcf721744b39
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Jul 28 18:52:14 2021 +0200

    clutter/layer-paint-node: Handle failure to allocate offscreen
    
    The failure to allocate was not properly handled, causing crashes later
    on due to the offscreen being NULL.
    
     #0  cogl_gl_framebuffer_bind (target=36160, gl_framebuffer=0x0)
     #1  _cogl_driver_gl_flush_framebuffer_state (...)
     #2  cogl_context_flush_framebuffer_state (read_buffer=0x55f48f386780, draw_buffer=0x55f48f386780, ...)
     #3  cogl_framebuffer_clear4f (framebuffer=0x55f48f386780, ...)
     #4  clutter_layer_node_pre_draw (...)
     #5  clutter_paint_node_paint (...)
    
    ...
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1942>

 clutter/clutter/clutter-paint-nodes.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/clutter/clutter/clutter-paint-nodes.c b/clutter/clutter/clutter-paint-nodes.c
index 0ab725b976..8ca5099887 100644
--- a/clutter/clutter/clutter-paint-nodes.c
+++ b/clutter/clutter/clutter-paint-nodes.c
@@ -1556,7 +1556,7 @@ clutter_layer_node_new (const graphene_matrix_t *projection,
   CoglTexture2D *tex_2d;
   CoglTexture *texture;
   CoglColor color;
-  CoglOffscreen *offscreen;
+  g_autoptr (CoglOffscreen) offscreen = NULL;
   g_autoptr (GError) error = NULL;
 
   lnode = _clutter_paint_node_create (CLUTTER_TYPE_LAYER_NODE);
@@ -1582,11 +1582,11 @@ clutter_layer_node_new (const graphene_matrix_t *projection,
     {
       g_warning ("Unable to create an allocate paint node offscreen: %s",
                  error->message);
-      g_object_unref (offscreen);
-      goto out;
+      cogl_object_unref (texture);
+      return NULL;
     }
 
-  lnode->offscreen = COGL_FRAMEBUFFER (offscreen);
+  lnode->offscreen = COGL_FRAMEBUFFER (g_steal_pointer (&offscreen));
 
   cogl_color_init_from_4ub (&color, opacity, opacity, opacity, opacity);
 
@@ -1601,7 +1601,6 @@ clutter_layer_node_new (const graphene_matrix_t *projection,
   cogl_pipeline_set_layer_texture (lnode->pipeline, 0, texture);
   cogl_pipeline_set_color (lnode->pipeline, &color);
 
-out:
   cogl_object_unref (texture);
 
   return (ClutterPaintNode *) lnode;


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