Skip to content

Commit 16d7d9d

Browse files
binarymasterJoachimHenze
authored andcommitted
[0.4.9] cherry-pick [MSPAINT] Fix divide by zero in drawZoomFrame
CORE-14539 #resolve (cherry picked from commit 8c726ae)
1 parent 22a0c67 commit 16d7d9d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

base/applications/mspaint/imgarea.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ void CImgAreaWindow::drawZoomFrame(int mouseX, int mouseY)
4141
int x, y, w, h;
4242
scrollboxWindow.GetClientRect(&clientRectScrollbox);
4343
GetClientRect(&clientRectImageArea);
44-
w = clientRectImageArea.right * clientRectScrollbox.right / (clientRectImageArea.right * 2);
45-
h = clientRectImageArea.bottom * clientRectScrollbox.bottom / (clientRectImageArea.bottom * 2);
44+
w = clientRectImageArea.right * 2;
45+
h = clientRectImageArea.bottom * 2;
46+
if (!w || !h)
47+
{
48+
return;
49+
}
50+
w = clientRectImageArea.right * clientRectScrollbox.right / w;
51+
h = clientRectImageArea.bottom * clientRectScrollbox.bottom / h;
4652
x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2));
4753
y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2));
4854

0 commit comments

Comments
 (0)