[geos-commits] r2219 - in branches/3.0/source: geomgraph
headers/geos/geomgraph operation/overlay
svn_geos at osgeo.org
svn_geos at osgeo.org
Tue Nov 11 12:31:37 EST 2008
Author: pramsey
Date: 2008-11-11 12:31:37 -0500 (Tue, 11 Nov 2008)
New Revision: 2219
Modified:
branches/3.0/source/geomgraph/EdgeList.cpp
branches/3.0/source/headers/geos/geomgraph/EdgeList.h
branches/3.0/source/operation/overlay/OverlayOp.cpp
Log:
Memory leak when one geometry is invalid on intersection(). (#170) From Denise Macleod.
Modified: branches/3.0/source/geomgraph/EdgeList.cpp
===================================================================
--- branches/3.0/source/geomgraph/EdgeList.cpp 2008-11-05 20:52:45 UTC (rev 2218)
+++ branches/3.0/source/geomgraph/EdgeList.cpp 2008-11-11 17:31:37 UTC (rev 2219)
@@ -128,6 +128,15 @@
#endif
}
+void
+EdgeList::clearList()
+{
+ for (unsigned int pos=0; pos < edges.size(); pos++)
+ delete *(&edges[pos]);
+
+ edges.clear();
+}
+
std::ostream&
operator<< (std::ostream&os, const EdgeList& el)
{
Modified: branches/3.0/source/headers/geos/geomgraph/EdgeList.h
===================================================================
--- branches/3.0/source/headers/geos/geomgraph/EdgeList.h 2008-11-05 20:52:45 UTC (rev 2218)
+++ branches/3.0/source/headers/geos/geomgraph/EdgeList.h 2008-11-11 17:31:37 UTC (rev 2219)
@@ -84,6 +84,8 @@
std::string print();
+ void clearList();
+
};
std::ostream& operator<< (std::ostream& os, const EdgeList& el);
Modified: branches/3.0/source/operation/overlay/OverlayOp.cpp
===================================================================
--- branches/3.0/source/operation/overlay/OverlayOp.cpp 2008-11-05 20:52:45 UTC (rev 2218)
+++ branches/3.0/source/operation/overlay/OverlayOp.cpp 2008-11-11 17:31:37 UTC (rev 2219)
@@ -685,18 +685,25 @@
// Will throw TopologyException if noding is found to be invalid
EdgeNodingValidator nv(edgeList.getEdges());
-#ifdef GEOS_DEBUG_VALIDATION // {
try {
nv.checkValid();
} catch (const util::TopologyException& ex) {
+#ifdef GEOS_DEBUG_VALIDATION // {
cout << "EdgeNodingValidator found noding invalid: " << ex.what() << endl;
+#endif // }
+ // In the error scenario, the edgeList is not properly
+ // deleted. Cannot add to the destructor of EdgeList
+ // (as it should) because
+ // "graph.addEdges(edgeList.getEdges());" below
+ // takes over edgeList ownership in the success case.
+ edgeList.clearList();
+
throw ex;
}
+#ifdef GEOS_DEBUG_VALIDATION // {
cout << "EdgeNodingValidator accepted the noding" << endl;
+#endif // }
-#else // }{
- nv.checkValid();
-#endif // }
}
#ifdef GEOS_DEBUG_VALIDATION // {
else
More information about the geos-commits
mailing list