[mapserver-commits] r10625 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Tue Oct 19 12:23:39 EDT 2010


Author: warmerdam
Date: 2010-10-19 09:23:38 -0700 (Tue, 19 Oct 2010)
New Revision: 10625

Modified:
   trunk/mapserver/mapogroutput.c
   trunk/mapserver/maputil.c
Log:
fix various memory leaks, partial implementation of Evens patch (#3570)

Modified: trunk/mapserver/mapogroutput.c
===================================================================
--- trunk/mapserver/mapogroutput.c	2010-10-19 15:51:07 UTC (rev 10624)
+++ trunk/mapserver/mapogroutput.c	2010-10-19 16:23:38 UTC (rev 10625)
@@ -221,8 +221,6 @@
 /* -------------------------------------------------------------------- */
     else if(  shape->type == MS_SHAPE_LINE )
     {
-        hGeom = OGR_G_CreateGeometry( wkbLineString );
-        
         if( shape->numlines != 1 || shape->line[0].numpoints < 2 )
         {
             msSetError(MS_MISCERR, 
@@ -231,6 +229,8 @@
             return MS_FAILURE;
         }
 
+        hGeom = OGR_G_CreateGeometry( wkbLineString );
+        
         for( i = 0; i < shape->line[0].numpoints; i++ )
         {
             OGR_G_SetPoint( hGeom, i, 
@@ -247,8 +247,6 @@
     {
         int iRing;
 
-        hGeom = OGR_G_CreateGeometry( wkbPolygon );
-        
         if( shape->numlines < 1 )
         {
             msSetError(MS_MISCERR, 
@@ -257,6 +255,8 @@
             return MS_FAILURE;
         }
 
+        hGeom = OGR_G_CreateGeometry( wkbPolygon );
+        
         for( iRing = 0; iRing < shape->numlines; iRing++ )
         {
             OGRGeometryH hRing = OGR_G_CreateGeometry( wkbLinearRing );
@@ -471,6 +471,7 @@
         strcpy( datasource_name, "/vsistdout/" );
     
     msFree( request_dir );
+    request_dir = NULL;
 
 /* -------------------------------------------------------------------- */
 /*      Emit content type headers for stream output now.                */
@@ -489,6 +490,7 @@
 /*      Create the datasource.                                          */
 /* ==================================================================== */
     hDS = OGR_Dr_CreateDataSource( hDriver,  datasource_name, ds_options );
+    CSLDestroy( ds_options );
     
     if( hDS == NULL )
     {
@@ -586,6 +588,7 @@
                                         layer_options );
         if( hOGRLayer == NULL )
         {
+            OGR_DS_Destroy( hDS );
             msOGRCleanupDS( datasource_name );
             msSetError( MS_MISCERR, 
                         "OGR CreateDataSource failed for '%s' with driver '%s'.",
@@ -595,6 +598,9 @@
             return MS_FAILURE;
         }
 
+        if( srs != NULL )
+            OSRDestroySpatialReference( srs );
+
 /* -------------------------------------------------------------------- */
 /*      Create appropriate attributes on this layer.                    */
 /* -------------------------------------------------------------------- */
@@ -650,6 +656,7 @@
                             layer->items[i], 
                             CPLGetLastErrorMsg() );
                 
+                OGR_DS_Destroy( hDS );
                 msOGRCleanupDS( datasource_name );
                 return MS_FAILURE;
             }
@@ -663,6 +670,7 @@
             for(j=0; j<layer->numjoins; j++) {
                 status = msJoinConnect(layer, &(layer->joins[j]));
                 if(status != MS_SUCCESS) {
+                    OGR_DS_Destroy( hDS );
                     msOGRCleanupDS( datasource_name );
                     return status;
                 }
@@ -683,6 +691,7 @@
                 layer, &resultshape,  layer->resultcache->results[i].tileindex,
                 layer->resultcache->results[i].shapeindex );
             if(status != MS_SUCCESS) {
+                OGR_DS_Destroy( hDS );
                 msOGRCleanupDS( datasource_name );
                 return status;
             } 
@@ -732,6 +741,7 @@
                                           item_list );
 
             if(status != MS_SUCCESS) {
+                OGR_DS_Destroy( hDS );
                 msOGRCleanupDS( datasource_name );
                 return status;
             } 
@@ -888,6 +898,7 @@
             fp = VSIFOpenL( file_list[i], "r" );
             if( fp == NULL )
             {
+                CPLCloseZip( hZip );
                 msSetError( MS_MISCERR, 
                             "Failed to open result file '%s'.",
                             "msOGRWriteFromQuery()",
@@ -944,6 +955,7 @@
 
     msOGRCleanupDS( datasource_name );
 
+    CSLDestroy( layer_options );
     CSLDestroy( file_list );
 
     return MS_SUCCESS;

Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c	2010-10-19 15:51:07 UTC (rev 10624)
+++ trunk/mapserver/maputil.c	2010-10-19 16:23:38 UTC (rev 10625)
@@ -1827,6 +1827,9 @@
   msGDALCleanup();
 #endif    
 #ifdef USE_PROJ
+#  if PJ_VERSION >= 480
+  pj_clear_initcache();
+#  endif
   pj_deallocate_grids();
   msSetPROJ_LIB( NULL );
 #endif



More information about the mapserver-commits mailing list