Changeset 18678 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2023-03-01T15:17:42+01:00 (20 months ago)
Author:
taylor.smock
Message:

Fix CID-1505775: Dereference null return value

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java

    r18553 r18678  
    1212import org.openstreetmap.josm.data.SystemOfMeasurement;
    1313import org.openstreetmap.josm.data.conflict.Conflict;
     14import org.openstreetmap.josm.data.coor.EastNorth;
    1415import org.openstreetmap.josm.data.coor.ILatLon;
    1516import org.openstreetmap.josm.data.coor.LatLon;
     
    173174        } else if (o instanceof IWay) {
    174175            addBbox(o);
    175             add(tr("Centroid: "), toStringCSV(false,
    176                     ProjectionRegistry.getProjection().eastNorth2latlon(Geometry.getCentroid(((IWay<?>) o).getNodes()))));
     176            final EastNorth centroid = Geometry.getCentroid(((IWay<?>) o).getNodes());
     177            final String centroidMessage;
     178            if (centroid == null) {
     179                centroidMessage = tr("unknown");
     180            } else {
     181                centroidMessage = toStringCSV(false,
     182                        ProjectionRegistry.getProjection().eastNorth2latlon(centroid));
     183            }
     184            add(tr("Centroid: "), centroidMessage);
    177185            if (o instanceof Way) {
    178186                double length = ((Way) o).getLength();
Note: See TracChangeset for help on using the changeset viewer.