From 51b1b102bd619b6a802807bde5f5228c1dabd1d7 Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Fri, 13 Mar 2020 17:10:08 +0200 Subject: st/mesa: Fix signed integer overflow when using util_throttle_memory_usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../src/mesa/state_tracker/st_cb_texture.c:1719:57: runtime error: signed integer overflow: 203489280 * 16 cannot be represented in type 'int' Fixes: 21ca322e637291b89a445159fc45b8dbf638e6c9 Signed-off-by: Danylo Piliaiev Reviewed-by: Marek Olšák Tested-by: Marge Bot Part-of: --- src/mesa/state_tracker/st_cb_texture.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 88951f5059d..d5dd61935bc 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1511,7 +1511,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims, } util_throttle_memory_usage(pipe, &st->throttle, - width * height * depth * + (uint64_t) width * height * depth * util_format_get_blocksize(dst->format)); u_box_3d(xoffset, yoffset, zoffset + dstz, width, height, depth, &box); @@ -1620,7 +1620,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims, } util_throttle_memory_usage(pipe, &st->throttle, - width * height * depth * + (uint64_t) width * height * depth * util_format_get_blocksize(src_templ.format)); throttled = true; @@ -1716,7 +1716,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims, fallback: if (!throttled) { util_throttle_memory_usage(pipe, &st->throttle, - width * height * depth * + (uint64_t) width * height * depth * _mesa_get_format_bytes(texImage->TexFormat)); } _mesa_store_texsubimage(ctx, dims, texImage, xoffset, yoffset, zoffset, -- cgit v1.2.3