Skip to content

Commit

Permalink
CPL_length(): fix unchecked cast to OGRGeometryCollection
Browse files Browse the repository at this point in the history
The current implementation would likely crash on things like
OGRPolyhedralSurface.
  • Loading branch information
rouault committed Nov 1, 2024
1 parent 0d1a48b commit fdfbf98
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/gdal_geom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ Rcpp::NumericVector CPL_length(Rcpp::List sfc) {
}
break;
default: {
OGRGeometryCollection *a = (OGRGeometryCollection *) g[i];
out[i] = a->get_Length();
if (OGR_GT_IsSubClassOf(gt, wkbGeometryCollection)) {
OGRGeometryCollection *a = (OGRGeometryCollection *) g[i];
out[i] = a->get_Length();
} else {
out[i] = 0.0;
}
}
}
OGRGeometryFactory f;
Expand Down

0 comments on commit fdfbf98

Please sign in to comment.