programs/explorer: Ensure launchers_per_row is at least 1 as it is used in divisions

Bruno Jesus 00cpxxx at gmail.com
Tue Dec 6 17:32:27 CST 2016


With some specific games running in virtual desktop (eg The Adventures
of Shuggy) I'm randomly getting an explorer crash while I think the
game is doing screen resolution changes.

The crash happens because the result of launchers_per_row is zero and
there are some places were it uses the value for divisions which
result in division by zero crash.

Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
-------------- next part --------------
diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c
index d306bb9..7366301 100644
--- a/programs/explorer/desktop.c
+++ b/programs/explorer/desktop.c
@@ -555,6 +555,12 @@ static void initialize_launchers( HWND hwnd )
     title_offset_cy = BORDER_SIZE + icon_size + PADDING_SIZE;
     desktop_width = GetSystemMetrics( SM_CXSCREEN );
     launchers_per_row = desktop_width / launcher_size;
+    if (!launchers_per_row)
+    {
+        WINE_WARN("Desktop width %d is too narrow to accommodate a launcher with width %d\n",
+                  desktop_width, launcher_size);
+        launchers_per_row = 1;
+    }
 
     hr = SHGetKnownFolderPath( &FOLDERID_Desktop, KF_FLAG_CREATE, NULL, &desktop_folder );
     if (FAILED( hr ))


More information about the wine-patches mailing list