Index: src/uk/me/parabola/imgfmt/app/Area.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/Area.java	(revision 3993)
+++ src/uk/me/parabola/imgfmt/app/Area.java	(working copy)
@@ -17,6 +17,7 @@
 package uk.me.parabola.imgfmt.app;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 import uk.me.parabola.imgfmt.MapFailedException;
@@ -68,6 +69,27 @@
 				, Utils.toMapUnit(maxLat), Utils.toMapUnit(maxLong));
 	}
 
+	public static Area calcBBox(Collection<Coord> points) {
+		int tmpMinLat = Integer.MAX_VALUE;
+		int tmpMinLong = Integer.MAX_VALUE;
+		int tmpMaxLat = Integer.MIN_VALUE;
+		int tmpMaxLong = Integer.MIN_VALUE;
+		for (Coord co: points) {
+			int lat = co.getLatitude();
+			if (lat < tmpMinLat)
+				tmpMinLat = lat;
+			if (lat > tmpMaxLat)
+				tmpMaxLat = lat;
+
+			int lon = co.getLongitude();
+			if (lon < tmpMinLong)
+				tmpMinLong = lon;
+			if (lon > tmpMaxLong)
+				tmpMaxLong = lon;
+		}
+		return new Area(tmpMinLat, tmpMinLong, tmpMaxLat, tmpMaxLong);
+	}
+	
 	public int getMinLat() {
 		return minLat;
 	}
@@ -321,4 +343,5 @@
 		return new Area(Math.max(minLat, other.minLat), Math.max(minLong, other.minLong),
 				Math.min(maxLat, other.maxLat), Math.min(maxLong, other.maxLong));
 	}
+	
 }
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(revision 3993)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(working copy)
@@ -31,6 +31,7 @@
 import java.util.logging.Level;
 
 import uk.me.parabola.imgfmt.ExitException;
+import uk.me.parabola.imgfmt.MapFailedException;
 import uk.me.parabola.imgfmt.app.Area;
 import uk.me.parabola.imgfmt.app.Coord;
 import uk.me.parabola.imgfmt.app.CoordNode;
@@ -140,6 +141,8 @@
 
 	private final boolean checkRoundabouts;
 	private int reportDeadEnds; 
+	private int countBadData;
+
 	private final boolean linkPOIsToWays;
 	private final boolean mergeRoads;
 	private final boolean routable;
@@ -325,6 +328,16 @@
 			else
 				rules = wayRules;
 		}
+		
+		// perform simple check to detect invalid data caused by I/O errors
+		String val = way.getTag("building");
+		if ("yes".equals(val)) {
+			if (!FakeIdGenerator.isFakeId(way.getId()) && Area.calcBBox(way.getPoints()).getMaxDimension() > 1000) {
+				log.error("Data integrety check failed: Building polygon has huge bbox", way.toBrowseURL());
+				++countBadData;
+			}
+		}
+		
 		Way cycleWay = null;
 		String cycleWayTag = way.getTag(makeCycleWayTagKey);
 		if ("yes".equals(cycleWayTag)){
@@ -596,6 +609,9 @@
 	}
 	
 	public void end() {
+		if (countBadData > 10)
+			throw new MapFailedException("Input file seems to be corrupted, counted "+ countBadData + " unplausable objects");
+		
 		pointMap.clear();
 		style.reportStats();
 		driveOnLeft = calcDrivingSide();
