Skip to content

Commit 0ef7d31

Browse files
committed
LineDissolver: Avoid null-pointer dereference
1 parent 5b0e56a commit 0ef7d31

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/dissolve/LineDissolver.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ LineDissolver::dissolve(const Geometry* g)
5050
void
5151
LineDissolver::add(const Geometry* geom)
5252
{
53+
if (factory == nullptr) {
54+
factory = geom->getFactory();
55+
}
56+
5357
struct LineStringFilter : public GeometryComponentFilter {
5458

5559
LineDissolver *m_ld;
@@ -83,9 +87,6 @@ LineDissolver::add(std::vector<const Geometry*> geometries)
8387
void
8488
LineDissolver::add(const LineString* lineString)
8589
{
86-
if (factory == nullptr) {
87-
factory = lineString->getFactory();
88-
}
8990
const CoordinateSequence* seq = lineString->getCoordinatesRO();
9091
bool doneStart = false;
9192
for (std::size_t i = 1; i < seq->size(); i++) {
@@ -129,6 +130,7 @@ LineDissolver::computeResult()
129130
if (MarkHalfEdge::isMarked(e)) continue;
130131
process(e);
131132
}
133+
132134
result = factory->buildGeometry(std::move(lines));
133135
}
134136

0 commit comments

Comments
 (0)