diff --git a/src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/MvtReader.java b/src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/MvtReader.java index 3d6cee7..e1ecbf2 100644 --- a/src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/MvtReader.java +++ b/src/main/java/com/wdtinc/mapbox_vector_tile/adapt/jts/MvtReader.java @@ -211,9 +211,13 @@ private static Geometry readPoints(GeometryFactory geomFactory, List ge // Guard: header data unsupported by geometry command buffer // (require header and at least 1 value * 2 params) - if(cmdLength * GeomCmd.MoveTo.getParamCount() + 1 > geomCmds.size()) { + int requiredgeomCmdsLength = cmdLength * GeomCmd.MoveTo.getParamCount() + 1; + if(requiredgeomCmdsLength > geomCmds.size()) { return null; } + if (requiredgeomCmdsLength < geomCmds.size()) { + geomCmds = geomCmds.subList(0, requiredgeomCmdsLength); // ignore extra commands... should it return null instead? + } final CoordinateSequence coordSeq = geomFactory.getCoordinateSequenceFactory().create(cmdLength, 2); int coordIndex = 0;