Changeset 18513 in josm


Ignore:
Timestamp:
2022-07-07T23:02:39+02:00 (2 years ago)
Author:
taylor.smock
Message:

Way: Fix IAE where getNodePairs would be called on an empty way

This fixes #22198 and #22199.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r18494 r18513  
    158158    public List<Pair<Node, Node>> getNodePairs(boolean sort) {
    159159        // For a way of size n, there are n - 1 pairs (a -> b, b -> c, c -> d, etc., 4 nodes -> 3 pairs)
    160         List<Pair<Node, Node>> chunkSet = new ArrayList<>(this.getNodesCount() - 1);
     160        List<Pair<Node, Node>> chunkSet = new ArrayList<>(Math.max(0, this.getNodesCount() - 1));
    161161        if (isIncomplete()) return chunkSet;
    162162        Node lastN = null;
Note: See TracChangeset for help on using the changeset viewer.