From 96b1ebb2fd5f10141e66fa53bfb2a50e181d9972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 28 Jul 2021 18:52:14 +0200 Subject: [PATCH] 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: --- 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 0ab725b97..8ca509988 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;