dlist: increment/check list nesting when handling OPCODE_CALL_LIST(S)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11493>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2021-06-16 17:44:29 +02:00 committed by Marge Bot
parent 764e28d238
commit 2f506e8153

View file

@ -11233,13 +11233,6 @@ execute_list(struct gl_context *ctx, GLuint list)
if (list == 0 || !_mesa_get_list(ctx, list, &dlist, true))
return;
if (ctx->ListState.CallDepth == MAX_LIST_NESTING) {
/* raise an error? */
return;
}
ctx->ListState.CallDepth++;
n = dlist->Head;
while (1) {
@ -11304,14 +11297,18 @@ execute_list(struct gl_context *ctx, GLuint list)
case OPCODE_CALL_LIST:
/* Generated by glCallList(), don't add ListBase */
if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
ctx->ListState.CallDepth++;
execute_list(ctx, n[1].ui);
ctx->ListState.CallDepth--;
}
break;
case OPCODE_CALL_LISTS:
if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
ctx->ListState.CallDepth++;
_mesa_HashUnlockMutex(ctx->Shared->DisplayList);
CALL_CallLists(ctx->Exec, (n[1].i, n[2].e, get_pointer(&n[3])));
_mesa_HashLockMutex(ctx->Shared->DisplayList);
ctx->ListState.CallDepth--;
}
break;
case OPCODE_CLEAR:
@ -13442,7 +13439,6 @@ execute_list(struct gl_context *ctx, GLuint list)
}
FALLTHROUGH;
case OPCODE_END_OF_LIST:
ctx->ListState.CallDepth--;
return;
}
@ -15000,12 +14996,9 @@ _mesa_glthread_execute_list(struct gl_context *ctx, GLuint list)
struct gl_display_list *dlist;
if (list == 0 ||
ctx->GLThread.ListCallDepth == MAX_LIST_NESTING ||
!_mesa_get_list(ctx, list, &dlist, true))
return;
ctx->GLThread.ListCallDepth++;
Node *n = dlist->Head;
while (1) {
@ -15014,12 +15007,18 @@ _mesa_glthread_execute_list(struct gl_context *ctx, GLuint list)
switch (opcode) {
case OPCODE_CALL_LIST:
/* Generated by glCallList(), don't add ListBase */
if (ctx->GLThread.ListCallDepth < MAX_LIST_NESTING)
if (ctx->GLThread.ListCallDepth < MAX_LIST_NESTING) {
ctx->GLThread.ListCallDepth++;
_mesa_glthread_execute_list(ctx, n[1].ui);
ctx->GLThread.ListCallDepth--;
}
break;
case OPCODE_CALL_LISTS:
if (ctx->GLThread.ListCallDepth < MAX_LIST_NESTING)
if (ctx->GLThread.ListCallDepth < MAX_LIST_NESTING) {
ctx->GLThread.ListCallDepth++;
_mesa_glthread_CallLists(ctx, n[1].i, n[2].e, get_pointer(&n[3]));
ctx->GLThread.ListCallDepth--;
}
break;
case OPCODE_DISABLE:
_mesa_glthread_Disable(ctx, n[1].e);
@ -15107,7 +15106,7 @@ _mesa_init_display_list(struct gl_context *ctx)
GLvertexformat *vfmt = &ctx->ListState.ListVtxfmt;
/* Display list */
ctx->ListState.CallDepth = 0;
ctx->ListState.CallDepth = 1;
ctx->ExecuteFlag = GL_TRUE;
ctx->CompileFlag = GL_FALSE;
ctx->ListState.CurrentBlock = NULL;