mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-08 23:40:12 +01:00
zink: Avoid the use of negative array offsets
Fix defect reported by Coverity Scan. Negative array index read A memory location at a negative offset from the beginning of the array will be read, resulting in incorrect values. CID: 1515600 Signed-off-by: Corentin Noël <corentin.noel@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26922>
This commit is contained in:
parent
920fe469b3
commit
a18171968c
1 changed files with 7 additions and 2 deletions
|
|
@ -878,8 +878,13 @@ zink_fb_clear_rewrite(struct zink_context *ctx, unsigned idx, enum pipe_format b
|
|||
*/
|
||||
const struct util_format_description *bdesc = util_format_description(before);
|
||||
const struct util_format_description *adesc = util_format_description(after);
|
||||
bool bsigned = bdesc->channel[util_format_get_first_non_void_channel(before)].type == UTIL_FORMAT_TYPE_SIGNED;
|
||||
bool asigned = adesc->channel[util_format_get_first_non_void_channel(after)].type == UTIL_FORMAT_TYPE_SIGNED;
|
||||
int bfirst_non_void_chan = util_format_get_first_non_void_channel(before);
|
||||
int afirst_non_void_chan = util_format_get_first_non_void_channel(after);
|
||||
bool bsigned = false, asigned = false;
|
||||
if (bfirst_non_void_chan > 0)
|
||||
bsigned = bdesc->channel[bfirst_non_void_chan].type == UTIL_FORMAT_TYPE_SIGNED;
|
||||
if (afirst_non_void_chan > 0)
|
||||
asigned = adesc->channel[afirst_non_void_chan].type == UTIL_FORMAT_TYPE_SIGNED;
|
||||
if (util_format_is_srgb(before) == util_format_is_srgb(after) &&
|
||||
bsigned == asigned)
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue