1
0
Fork 0

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>
This commit is contained in:
Jonas Ådahl 2021-07-28 18:52:14 +02:00 committed by Marge Bot
parent 5e5c7fe1af
commit 96b1ebb2fd

View file

@ -1556,7 +1556,7 @@ clutter_layer_node_new (const graphene_matrix_t *projection,
CoglTexture2D *tex_2d; CoglTexture2D *tex_2d;
CoglTexture *texture; CoglTexture *texture;
CoglColor color; CoglColor color;
CoglOffscreen *offscreen; g_autoptr (CoglOffscreen) offscreen = NULL;
g_autoptr (GError) error = NULL; g_autoptr (GError) error = NULL;
lnode = _clutter_paint_node_create (CLUTTER_TYPE_LAYER_NODE); 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", g_warning ("Unable to create an allocate paint node offscreen: %s",
error->message); error->message);
g_object_unref (offscreen); cogl_object_unref (texture);
goto out; 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); 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_layer_texture (lnode->pipeline, 0, texture);
cogl_pipeline_set_color (lnode->pipeline, &color); cogl_pipeline_set_color (lnode->pipeline, &color);
out:
cogl_object_unref (texture); cogl_object_unref (texture);
return (ClutterPaintNode *) lnode; return (ClutterPaintNode *) lnode;