Skip to content

Commit 77de5b4

Browse files
committed
Avoid a potential core crash when the content video mode changes and the on-screen mouse cursor becomes out of view (#686)
1 parent e8cb668 commit 77de5b4

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

dosbox_pure_osd.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,10 @@ struct DBP_MenuMouse
271271
// Draw white mouse cursor with black outline
272272
click = right_up = wheel_up = wheel_down = false;
273273
if (!realmouse && !joykbd) return;
274-
for (Bit32u thick = buf.GetThickness(), midc = 6*thick, maxc = 8*thick, *v = buf.video, w = buf.width, h = buf.height, i = 0; i != 9; i++)
274+
for (Bit32u thick = buf.GetThickness(), midc = 6*thick, maxc = 8*thick, *v = buf.video, w = buf.width, h = buf.height, *pendy = v + w * h, i = 0; i != 9; i++)
275275
{
276-
Bit32u n = (i < 4 ? i : (i < 8 ? i+1 : 4)), px = (Bit32u)x + (n%3)-1, py = (Bit32u)y + (n/3)-1, ccol = (n == 4 ? 0xFFFFFFFF : 0xFF000000);
277-
Bit32u *pp, *p = v + py * w + px, *pendx = p - px + w, *pendy = v + w * h;
278-
for (Bit32u c = 0; c != maxc; c++)
276+
Bit32u n = (i < 4 ? i : (i < 8 ? i+1 : 4)), px = (Bit32u)x + (n%3)-1, py = (Bit32u)y + (n/3)-1, ccol = (n == 4 ? 0xFFFFFFFF : 0xFF000000), *p = v + py * w + px;
277+
if (p < pendy) for (Bit32u *pp, *pendx = p - px + w, c = 0; c != maxc; c++)
279278
{
280279
if (c < midc && (pp = (p + c * w)) < pendy) *pp = ccol; // line down
281280
if ((pp = (p + c)) < pendx)

0 commit comments

Comments
 (0)