llvmpipe: Asserts that the format at least has one non-void channel

As we are using its index as array index, avoid the use of the -1 index there.

CID: 1517247, 1517239 Negative array index read
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35091>
This commit is contained in:
Corentin Noël 2025-05-20 16:24:03 +02:00 committed by Marge Bot
parent d2aade9184
commit 09938eee85

View file

@ -181,6 +181,7 @@ lp_mem_type_from_format_desc(const struct util_format_description *format_desc,
}
int chan = util_format_get_first_non_void_channel(format_desc->format);
assert(chan >= 0);
memset(type, 0, sizeof(struct lp_type));
type->floating = format_desc->channel[chan].type == UTIL_FORMAT_TYPE_FLOAT;
@ -1783,7 +1784,8 @@ lp_blend_type_from_format_desc(const struct util_format_description *format_desc
return;
}
const int chan = util_format_get_first_non_void_channel(format_desc->format);
int chan = util_format_get_first_non_void_channel(format_desc->format);
assert(chan >= 0);
memset(type, 0, sizeof(struct lp_type));
type->floating = format_desc->channel[chan].type == UTIL_FORMAT_TYPE_FLOAT;