]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/display/framebuffer: Add cast to force 64x64 multiply
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 10 Jul 2025 17:43:12 +0000 (18:43 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Fri, 1 Aug 2025 15:48:50 +0000 (16:48 +0100)
In framebuffer_update_display(), Coverity complains because we
multiply two values of type 'int' (which will be done as a 32x32
multiply and so in theory might overflow) and then add the result to
a ram_addr_t, which can be 64 bits.

4GB framebuffers are not plausible anyway, but keep Coverity happy
by adding casts which force these multiplies to be done as 64x64.

Coverity: CID 1487248
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Message-id: 20250710174312.1313177-1-peter.maydell@linaro.org

hw/display/framebuffer.c

index 4485aa335bbce829db75110463e0fc36a85729c0..b4296e8a33ec2c38a8148790a88fb92b66eb9e95 100644 (file)
@@ -95,9 +95,9 @@ void framebuffer_update_display(
     }
     first = -1;
 
-    addr += i * src_width;
-    src += i * src_width;
-    dest += i * dest_row_pitch;
+    addr += (uint64_t)i * src_width;
+    src += (uint64_t)i * src_width;
+    dest += (uint64_t)i * dest_row_pitch;
 
     snap = memory_region_snapshot_and_clear_dirty(mem, addr, src_width * rows,
                                                   DIRTY_MEMORY_VGA);