[mutter/wip/smcv/shell2538-robustness: 1/2] cogl: Don't allow creating sized textures with 0 pixels



commit 8e8544d7c4e4718ec52e8302f6bf166397674f4e
Author: Simon McVittie <smcv debian org>
Date:   Thu Apr 2 19:30:14 2020 +0100

    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.
    
    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/gnome-shell/-/issues/2538>.
    
    Signed-off-by: Simon McVittie <smcv debian org>

 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;


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