From 71db96ccc79b4e7ae62fcbdfbc8a35b06c32784d Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 8 Apr 2018 13:41:32 +0300 Subject: [PATCH] Fix divide by zero if pitch is zero. (single line blit) --- qemuvga/cirrus_vga.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qemuvga/cirrus_vga.cpp b/qemuvga/cirrus_vga.cpp index 9502dca9..9e6f53fc 100644 --- a/qemuvga/cirrus_vga.cpp +++ b/qemuvga/cirrus_vga.cpp @@ -188,9 +188,15 @@ static void check_blit(int32_t addr, uint32_t mask, int pitch, int width, int *h off -= width * (depth / 8); } if (off > mask + 1) { - h -= (off - (mask + 1) + pitch - 1) / pitch; + if (pitch) + h -= (off - (mask + 1) + pitch - 1) / pitch; + else + h = 0; } else if (off < 0) { - h -= ((-off) + pitch - 1) / pitch; + if (pitch) + h -= ((-off) + pitch - 1) / pitch; + else + h = 0; } if (h < 0) h = 0; -- 2.47.3