Skip to content

Commit 5f44d8d

Browse files
authored
Merge pull request #2469 from rouault/fix_CPL_length
CPL_length(): fix unchecked cast to OGRGeometryCollection
2 parents 0d1a48b + fdfbf98 commit 5f44d8d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/gdal_geom.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ Rcpp::NumericVector CPL_length(Rcpp::List sfc) {
6363
}
6464
break;
6565
default: {
66-
OGRGeometryCollection *a = (OGRGeometryCollection *) g[i];
67-
out[i] = a->get_Length();
66+
if (OGR_GT_IsSubClassOf(gt, wkbGeometryCollection)) {
67+
OGRGeometryCollection *a = (OGRGeometryCollection *) g[i];
68+
out[i] = a->get_Length();
69+
} else {
70+
out[i] = 0.0;
71+
}
6872
}
6973
}
7074
OGRGeometryFactory f;

0 commit comments

Comments
 (0)