Index: /trunk/src/org/openstreetmap/josm/tools/Geometry.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Geometry.java	(revision 15106)
+++ /trunk/src/org/openstreetmap/josm/tools/Geometry.java	(revision 15107)
@@ -1043,4 +1043,5 @@
     /**
      * Find all primitives in the given collection which are inside the given polygon.
+     * Unclosed ways and multipolygon relations with unclosed outer rings are ignored.
      * @param primitives the primitives
      * @param polygon the polygon
@@ -1061,10 +1062,12 @@
                 }
             } else if (p instanceof IWay) {
-                if (polygonArea == null) {
-                    polygonArea = getArea(polygon.getNodes());
-                }
-                if (PolygonIntersection.FIRST_INSIDE_SECOND == polygonIntersection(getArea(((IWay<?>) p).getNodes()),
-                        polygonArea)) {
-                    res.add(p);
+                if (((IWay<?>) p).isClosed()) {
+                    if (polygonArea == null) {
+                        polygonArea = getArea(polygon.getNodes());
+                    }
+                    if (PolygonIntersection.FIRST_INSIDE_SECOND == polygonIntersection(getArea(((IWay<?>) p).getNodes()),
+                            polygonArea)) {
+                        res.add(p);
+                    }
                 }
             } else if (p.isMultipolygon()) {
@@ -1076,6 +1079,7 @@
                 // a (valid) multipolygon is inside the polygon if all outer rings are inside
                 for (PolyData outer : mp.getOuterPolygons()) {
-                    if (PolygonIntersection.FIRST_INSIDE_SECOND != polygonIntersection(getArea(outer.getNodes()),
-                            polygonArea)) {
+                    if (!outer.isClosed()
+                            || PolygonIntersection.FIRST_INSIDE_SECOND != polygonIntersection(getArea(outer.getNodes()),
+                                    polygonArea)) {
                         inside = false;
                         break;
@@ -1092,5 +1096,5 @@
     /**
      * Find all primitives in the given collection which are inside the given multipolygon. Members of the multipolygon are
-     * ignored.
+     * ignored. Unclosed ways and multipolygon relations with unclosed outer rings are ignored.
      * @param primitives the primitives
      * @param multiPolygon the multipolygon relation
@@ -1121,5 +1125,5 @@
                 }
             } else if (p instanceof Way) {
-                if (isPolygonInsideMultiPolygon(((Way) p).getNodes(), outerInner, null)) {
+                if (((IWay<?>) p).isClosed() && isPolygonInsideMultiPolygon(((Way) p).getNodes(), outerInner, null)) {
                     res.add(p);
                 }
@@ -1129,5 +1133,5 @@
                 // a (valid) multipolygon is inside multiPolygon if all outer rings are inside
                 for (PolyData outer : mp.getOuterPolygons()) {
-                    if (!isPolygonInsideMultiPolygon(outer.getNodes(), outerInner, null)) {
+                    if (!outer.isClosed() || !isPolygonInsideMultiPolygon(outer.getNodes(), outerInner, null)) {
                         inside = false;
                         break;
