lima: avoid crash with negative viewport values
authorErico Nunes <nunes.erico@gmail.com>
Sun, 25 Jul 2021 11:48:59 +0000 (13:48 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 27 Jul 2021 08:48:28 +0000 (08:48 +0000)
commite6cdb01c517b42dece9ed532fd6eba7a74aa8f71
tree3986e0108459d56ba9c9528d30958e8f6e3b9099
parent11d6441b94c7bf59ee32c8bcb0e30d370f3bd42c
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>
src/gallium/drivers/lima/lima_draw.c