From 5cf6ab0cf42a10f04d5c234bc6c70eb64dd207c8 Mon Sep 17 00:00:00 2001 From: purplerain Date: Thu, 7 Mar 2024 06:43:52 +0000 Subject: [PATCH] Fix off-by-one in dlist allocation when checking whether to allocate a new block. This fixes segfaults in dlist functions that occur on applications making heavy use of display lists that exceed BLOCK_SIZE. --- lib/mesa/src/mesa/main/dlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mesa/src/mesa/main/dlist.c b/lib/mesa/src/mesa/main/dlist.c index 63feef2b..8c32ed80 100644 --- a/lib/mesa/src/mesa/main/dlist.c +++ b/lib/mesa/src/mesa/main/dlist.c @@ -1220,7 +1220,7 @@ dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes, bool align8) ctx->ListState.CurrentPos++; } - if (ctx->ListState.CurrentPos + numNodes + contNodes > BLOCK_SIZE) { + if (ctx->ListState.CurrentPos + numNodes + contNodes >= BLOCK_SIZE) { /* This block is full. Allocate a new block and chain to it */ Node *newblock; Node *n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;