]> granicus.if.org Git - postgis/commitdiff
Apply a slightly modified version of Dave Fuhry's patch for a memory leak in shp2pgsq...
authorMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Thu, 19 Nov 2009 15:15:55 +0000 (15:15 +0000)
committerMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Thu, 19 Nov 2009 15:15:55 +0000 (15:15 +0000)
git-svn-id: http://svn.osgeo.org/postgis/branches/1.4@4861 b70326c6-7e19-0410-871a-916f4a2858ee

loader/shp2pgsql.c

index 49007a8d9d938db32fff7893214393ce1fecf7aa..f834215d3141b4176b060327e4b573eeec4b6d2e 100644 (file)
@@ -461,6 +461,7 @@ main (int ARGC, char **ARGV)
 
        printf("END;\n"); /* End the last transaction */
 
+       Cleanup();
 
        return 0;
 }/*end main() */
@@ -1173,8 +1174,6 @@ InsertPolygon(void)
                lwpolygons[pi] = lwpoly_as_lwgeom(lwpoly);
        }
 
-       ReleasePolygons(Outer, polygon_total);
-
        /* If using MULTIPOLYGONS then generate the serialized collection, otherwise just a single POLYGON */
        if (simple_geometries == 0)
        {
@@ -1186,6 +1185,22 @@ InsertPolygon(void)
                serialized_lwgeom = lwgeom_serialize(lwpolygons[0]);
        }
 
+       for(pi = 0; pi < polygon_total; pi++)
+       {
+               Ring *polyring = Outer[pi];
+               int ring_index = 0;
+               while (polyring)
+               {
+                       lwfree(pas[pi][ring_index]->serialized_pointlist);
+                       lwfree(pas[pi][ring_index]);
+
+                       polyring = polyring->next;
+                       ring_index++;
+               }
+       }
+
+       ReleasePolygons(Outer, polygon_total);
+
        if (!hwgeom)
                result = serialized_lwgeom_to_hexwkb(&lwg_unparser_result, serialized_lwgeom, PARSER_CHECK_NONE, -1);
        else