I have spent time investigating this memory leak and produced a patch
that I believe fixes it. The patch is included in this mail.

The GEOS tests (make check) pass with this patch. However in one of my
private tests I found a one point difference in the simplified polyline
produced with and without the patch (one point missing with this patch).
Because the resulting polyline looks correct to me I decided to
incorporate the patch, however your decision may be different.


I would much appreciate it if someone more knowledgeable than I gave the
patch a look. Thank you.

Bill

diff -Naur geos-3.0.0/source/index/quadtree/NodeBase.cpp
geos-3.0.0.new/source/index/quadtree/NodeBase.cpp
--- geos-3.0.0/source/index/quadtree/NodeBase.cpp       2007-12-12
13:59:26.000000000 -0800
+++ geos-3.0.0.new/source/index/quadtree/NodeBase.cpp   2008-01-30
20:59:05.000000000 -0800
@@ -215,7 +215,10 @@
                        if (found) {
                                // trim subtree if empty
                                if (subnode[i]->isPrunable())
-                               subnode[i] = NULL;
+                               {
+                                       delete subnode[i];
+                                       subnode[i] = NULL;
+                               }
                                break;
                        }
                }
diff -Naur geos-3.0.0/source/index/quadtree/Quadtree.cpp
geos-3.0.0.new/source/index/quadtree/Quadtree.cpp
--- geos-3.0.0/source/index/quadtree/Quadtree.cpp       2007-12-12
13:59:26.000000000 -0800
+++ geos-3.0.0.new/source/index/quadtree/Quadtree.cpp   2008-01-30
20:59:05.000000000 -0800
@@ -142,7 +142,10 @@
 Quadtree::remove(const Envelope* itemEnv, void* item)
 {
        Envelope* posEnv = ensureExtent(itemEnv, minExtent);
-       return root->remove(posEnv, item);
+       bool result = root->remove(posEnv, item);
+       if (itemEnv != posEnv)
+               delete posEnv;
+       return result;
 }
 
 /*private*/
_______________________________________________
geos-devel mailing list
geos-devel@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-devel

Reply via email to