gallium/util: widen type before multiplication

This method returns size_t, but the multiplication multiplies two
integers, leading to overflow rather than type widening.

Noticed by compiling with MSVC, which emits a warning.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Erik Faye-Lund 2019-08-13 13:02:24 +02:00
parent 0091f62978
commit 18ab42644b

View file

@ -870,7 +870,7 @@ static inline size_t
util_format_get_stride(enum pipe_format format,
unsigned width)
{
return util_format_get_nblocksx(format, width) * util_format_get_blocksize(format);
return (size_t)util_format_get_nblocksx(format, width) * util_format_get_blocksize(format);
}
static inline size_t