Changeset 17559 in josm for trunk


Ignore:
Timestamp:
2021-03-13T01:44:36+01:00 (4 years ago)
Author:
Don-vip
Message:

fix #20587 - fix potential infinite loop in QuadBuckets toArray (patch by taylor.smock)

File:
1 edited

Legend:

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

    r17459 r17559  
    455455    @Override
    456456    public Object[] toArray() {
    457         return this.toList().toArray();
     457        // Don't call toList() -- in some cases, this can produce an infinite loop
     458        // For example, ArrayList may call toArray to get the initial array. However, since we are
     459        // creating a new ArrayList in toList with `this`, this creates an infinite recursion loop.
     460        // So a `toArray` call becomes `toArray -> toList -> toArray -> toList -> toArray -> ...`
     461        // For more information, see #20587.
     462        return this.stream().toArray();
    458463    }
    459464
Note: See TracChangeset for help on using the changeset viewer.