[MSPAINT] Fix divide by zero in drawZoomFrame
authorStanislav Motylkov <x86corez@gmail.com>
Wed, 23 May 2018 21:31:20 +0000 (00:31 +0300)
committerHermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Wed, 23 May 2018 21:40:28 +0000 (23:40 +0200)
CORE-14539 #resolve

base/applications/mspaint/imgarea.cpp

index c9b1b3f..433fc7b 100644 (file)
@@ -41,8 +41,14 @@ void CImgAreaWindow::drawZoomFrame(int mouseX, int mouseY)
     int x, y, w, h;
     scrollboxWindow.GetClientRect(&clientRectScrollbox);
     GetClientRect(&clientRectImageArea);
-    w = clientRectImageArea.right * clientRectScrollbox.right / (clientRectImageArea.right * 2);
-    h = clientRectImageArea.bottom * clientRectScrollbox.bottom / (clientRectImageArea.bottom * 2);
+    w = clientRectImageArea.right * 2;
+    h = clientRectImageArea.bottom * 2;
+    if (!w || !h)
+    {
+        return;
+    }
+    w = clientRectImageArea.right * clientRectScrollbox.right / w;
+    h = clientRectImageArea.bottom * clientRectScrollbox.bottom / h;
     x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2));
     y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2));