[gtk/4.0-backports: 1/53] Abort if the shared memory pool cannot be created
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/4.0-backports: 1/53] Abort if the shared memory pool cannot be created
- Date: Sun, 7 Feb 2021 17:49:40 +0000 (UTC)
commit 201580b4436c390bcde31101ee9e2b6a8f30de67
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Jan 20 19:10:54 2021 +0000
Abort if the shared memory pool cannot be created
If we cannot allocate memory, we cannot create any windowing system
surface. There's no coming back from that.
Fixes: #3607
gdk/wayland/gdkdisplay-wayland.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index f5ea972fa2..3acc10ed50 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -1350,21 +1350,23 @@ _gdk_wayland_display_create_shm_surface (GdkWaylandDisplay *display,
data->buffer = NULL;
data->scale = scale;
- stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width*scale);
+ stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width * scale);
data->pool = create_shm_pool (display->shm,
- height*scale*stride,
+ height * scale * stride,
&data->buf_length,
&data->buf);
+ if (G_UNLIKELY (data->pool == NULL))
+ g_error ("Unable to create shared memory pool");
surface = cairo_image_surface_create_for_data (data->buf,
CAIRO_FORMAT_ARGB32,
- width*scale,
- height*scale,
+ width * scale,
+ height * scale,
stride);
data->buffer = wl_shm_pool_create_buffer (data->pool, 0,
- width*scale, height*scale,
+ width * scale, height * scale,
stride, WL_SHM_FORMAT_ARGB8888);
cairo_surface_set_user_data (surface, &gdk_wayland_shm_surface_cairo_key,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]