Permalink
Browse files

Fixes potential nullref exception on MultiGeometry

When the MultiGeometry object doesn't have a geometries child this caused
a crash. Shouldn't crash, should just result in an invalid geoJson.
Added a test for this.
  • Loading branch information...
1 parent feb33b0 commit af620c9197dcf6d00a3e02f8f1d382138af46322 @vincentsels vincentsels committed Jan 27, 2016
View
@@ -146,7 +146,7 @@ var geometry = {
},
valid: function(_) {
return _ && _.type && (_.coordinates ||
- _.type === 'GeometryCollection' && _.geometries.every(geometry.valid));
+ _.type === 'GeometryCollection' && _.geometries && _.geometries.every(geometry.valid));
},
any: function(_) {
if (geometry[_.type]) {
@@ -0,0 +1,13 @@
+{ "type": "FeatureCollection",
+ "features": [{
+ "type": "Feature",
+ "geometry": {
+ "type": "GeometryCollection"
+ },
+ "properties": {
+ "prop0": "value0",
+ "prop1": "val2"
+ }
+ }
+ ]
+}
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"><Document></Document></kml>
View
@@ -40,6 +40,7 @@ test('tokml', function(t) {
geq(tt, 'multipoint');
geq(tt, 'multipolygon');
geq(tt, 'geometrycollection');
+ geq(tt, 'geometrycollection_nogeometries');
tt.end();
});
@@ -144,7 +145,7 @@ test('tokml', function(t) {
try {
tokml(gen);
} catch(e) {
- tt.fail('failed ' + JSON.stringify(gen) + 'with ' + e + e.stack);
+ tt.fail('failed at fuzzed version of ' + gj + ': ' + JSON.stringify(gen) + 'with ' + e + e.stack);
}
}
});

0 comments on commit af620c9

Please sign in to comment.