mesa: fix glBitmap in display lists when width <= 0 || height <= 0
authorMarek Olšák <marek.olsak@amd.com>
Wed, 31 May 2023 15:09:03 +0000 (11:09 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 8 Jun 2023 15:30:33 +0000 (15:30 +0000)
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8904
Fixes: bb860f63 - mesa: create glBitmap textures while creating display lists

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23335>

src/mesa/main/dlist.c

index 0dc90bb..63feef2 100644 (file)
@@ -1345,12 +1345,15 @@ save_Bitmap(GLsizei width, GLsizei height,
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
-   struct pipe_resource *tex =
-      st_make_bitmap_texture(ctx, width, height, &ctx->Unpack, pixels);
+   struct pipe_resource *tex = NULL;
 
-   if (!tex) {
-      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glNewList -> glBitmap");
-      return;
+   if (width > 0 && height > 0) {
+      tex = st_make_bitmap_texture(ctx, width, height, &ctx->Unpack, pixels);
+
+      if (!tex) {
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glNewList -> glBitmap");
+         return;
+      }
    }
 
    n = alloc_instruction(ctx, OPCODE_BITMAP, 6 + POINTER_DWORDS);