mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-20 23:00:36 +02:00
lima: avoid crash with negative viewport values
The viewport value computations done in lima_set_viewport_states can result in a negative value for viewport. These could end up converted to unsigned values in lima_clip_scissor_to_viewport causing crashes from invalid scissor commands. Prevent this by limiting the minimum value to zero as is already done for the left and bottom values. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2938 Cc: mesa-stable Signed-off-by: Erico Nunes <nunes.erico@gmail.com> Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12055>
This commit is contained in:
parent
11d6441b94
commit
e6cdb01c51
1 changed files with 2 additions and 2 deletions
|
|
@ -72,14 +72,14 @@ lima_clip_scissor_to_viewport(struct lima_context *ctx)
|
|||
|
||||
viewport_left = MAX2(ctx->viewport.left, 0);
|
||||
cscissor->minx = MAX2(cscissor->minx, viewport_left);
|
||||
viewport_right = MIN2(ctx->viewport.right, fb->base.width);
|
||||
viewport_right = MIN2(MAX2(ctx->viewport.right, 0), fb->base.width);
|
||||
cscissor->maxx = MIN2(cscissor->maxx, viewport_right);
|
||||
if (cscissor->minx > cscissor->maxx)
|
||||
cscissor->minx = cscissor->maxx;
|
||||
|
||||
viewport_bottom = MAX2(ctx->viewport.bottom, 0);
|
||||
cscissor->miny = MAX2(cscissor->miny, viewport_bottom);
|
||||
viewport_top = MIN2(ctx->viewport.top, fb->base.height);
|
||||
viewport_top = MIN2(MAX2(ctx->viewport.top, 0), fb->base.height);
|
||||
cscissor->maxy = MIN2(cscissor->maxy, viewport_top);
|
||||
if (cscissor->miny > cscissor->maxy)
|
||||
cscissor->miny = cscissor->maxy;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue