From 37eda498f2de2cf787a5e65d6f0248e4a8e33490 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 2 Apr 2020 19:30:14 +0100 Subject: [PATCH] cogl: Don't allow creating sized textures with 0 pixels A texture with no pixels isn't a useful thing to have, and breaks assumptions elsewhere. For example, CoglFramebuffer assumes that after a texture has been allocated, it will have width and height both greater than 0. In particular, this works around a crash when gnome-shell tries to blur a background that hasn't yet had any space allocated for it - which it seems is really an actor layout bug, but more robustness seems good to have. Workaround for . https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1172 Signed-off-by: Simon McVittie --- cogl/cogl/cogl-texture-2d.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c index 21a3c3fb6..a99cbb31e 100644 --- a/cogl/cogl/cogl-texture-2d.c +++ b/cogl/cogl/cogl-texture-2d.c @@ -121,6 +121,9 @@ cogl_texture_2d_new_with_size (CoglContext *ctx, { CoglTextureLoader *loader; + g_return_val_if_fail (width >= 1, NULL); + g_return_val_if_fail (height >= 1, NULL); + loader = _cogl_texture_create_loader (); loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED; loader->src.sized.width = width;