Index: /applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/TileRange.java
===================================================================
--- /applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/TileRange.java	(revision 36197)
+++ /applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/TileRange.java	(revision 36198)
@@ -48,9 +48,10 @@
      * Returns size
      * @return size
+     * @throws ArithmeticException – if the result overflows an int (see {@link Math#multiplyExact(int, int)})
      */
-    public int size() {
+    public int size() throws ArithmeticException {
         int xSpan = maxX - minX + 1;
         int ySpan = maxY - minY + 1;
-        return xSpan * ySpan;
+        return Math.multiplyExact(xSpan, ySpan);
     }
 }
Index: /applications/viewer/jmapviewer/test/org/openstreetmap/gui/jmapviewer/TileRangeTest.java
===================================================================
--- /applications/viewer/jmapviewer/test/org/openstreetmap/gui/jmapviewer/TileRangeTest.java	(revision 36197)
+++ /applications/viewer/jmapviewer/test/org/openstreetmap/gui/jmapviewer/TileRangeTest.java	(revision 36198)
@@ -4,4 +4,5 @@
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import org.junit.jupiter.api.Test;
@@ -21,3 +22,12 @@
                 new TileXY(6, 6), 10).size());
     }
+
+    /**
+     * Ensure that something exceptional happens when an integer overflow happens
+     */
+    @Test
+    void testSizeTooLarge() {
+        final TileRange allZ16 = new TileRange(new TileXY(0, 0), new TileXY(1 << 16, 1 << 16), 16);
+        assertThrows(ArithmeticException.class, allZ16::size);
+    }
 }
