]> granicus.if.org Git - nethack/commitdiff
Prevent crash caused by division by zero in NetHackW.
authorBart House <bart@barthouse.com>
Sat, 21 Dec 2019 23:34:57 +0000 (15:34 -0800)
committerBart House <bart@barthouse.com>
Sat, 21 Dec 2019 23:34:57 +0000 (15:34 -0800)
win/win32/mhmap.c

index 28308913d369c5ea23a7a17cbc6579dbe8552b5e..7569314a83b3360c425c917634f3e2c0f58230c9 100644 (file)
@@ -308,6 +308,10 @@ mswin_map_stretch(HWND hWnd, LPSIZE map_size, BOOL redraw)
     data->xFrontTile = (int) ((double) data->xBackTile * data->frontScale);
     data->yFrontTile = (int) ((double) data->yBackTile * data->frontScale);
 
+    /* ensure front tile is non-zero in size */
+    data->xFrontTile = max(data->xFrontTile, 1);
+    data->yFrontTile = max(data->yFrontTile, 1);
+
     /* calcuate ASCII cursor height */
     data->yBlinkCursor = (int) ((double) CURSOR_HEIGHT * data->backScale);
     data->yNoBlinkCursor = data->yBackTile;