softpipe: Fix the const buffer overflow check.

The size is in bytes, pos is a dword index.

Fixes these asan failures (not tested in CI since we run a fraction):

dEQP-GLES31.functional.shaders.opaque_type_indexing.ubo.const_expression_compute,Crash
dEQP-GLES31.functional.shaders.opaque_type_indexing.ubo.const_literal_compute,Crash

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9162>
This commit is contained in:
Eric Anholt 2021-02-18 16:31:00 -08:00 committed by Marge Bot
parent f88d03c16c
commit e08a04a140

View file

@ -1461,7 +1461,7 @@ fetch_src_file_channel(const struct tgsi_exec_machine *mach,
const uint constbuf = index2D->i[i];
const int pos = index->i[i] * 4 + swizzle;
/* const buffer bounds check */
if (pos < 0 || pos >= (int) mach->ConstsSize[constbuf]) {
if (pos < 0 || pos >= (int) mach->ConstsSize[constbuf] / 4) {
if (0) {
/* Debug: print warning */
static int count = 0;