--- ../mapserver-5.6.0-beta1/mapcontext.c	Mon Aug 31 19:13:45 2009
+++ mapcontext.c	Mon Nov  2 12:57:37 2009
@@ -1993,8 +1993,10 @@ int msWriteMapContext(mapObj *map, FILE *stream)
                   pszChar = strchr(pszStyle, ',');
                   if(pszChar != NULL)
                       pszStyle[pszChar - pszStyle] = '\0';
-                  if(strcasecmp(pszStyle, "") == 0)
+                  if(strcasecmp(pszStyle, "") == 0) {
+                      free(pszStyle);
                       continue;
+                  }
 
                   if(pszCurrent && (strcasecmp(pszStyle, pszCurrent) == 0))
                       msIO_fprintf( stream,"        <Style current=\"1\">\n" );
--- ../mapserver-5.6.0-beta1/mapgdal.c	Mon Aug 17 18:22:53 2009
+++ mapgdal.c	Mon Nov  2 13:01:28 2009
@@ -226,6 +226,8 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, cha
         msReleaseLock( TLOCK_GDAL );
         msSetError( MS_MISCERR, "Failed to find MEM driver.",
                     "msSaveImageGDAL()" );
+        if( pabyAlphaLine != NULL )
+            free( pabyAlphaLine );
         return MS_FAILURE;
     }
    
@@ -237,6 +239,8 @@ int msSaveImageGDAL( mapObj *map, imageObj *image, cha
         msReleaseLock( TLOCK_GDAL );
         msSetError( MS_MISCERR, "Failed to create MEM dataset.",
                     "msSaveImageGDAL()" );
+        if( pabyAlphaLine != NULL )
+            free( pabyAlphaLine );
         return MS_FAILURE;
     }
     
--- ../mapserver-5.6.0-beta1/mapshape.c	Wed Jul 22 06:20:44 2009
+++ mapshape.c	Mon Nov  2 13:13:37 2009
@@ -462,13 +462,17 @@ SHPHandle msSHPCreate( const char * pszLayer, int nSha
   pszFullname = (char *) malloc(strlen(pszBasename) + 5);
   sprintf( pszFullname, "%s.shp", pszBasename );
   fpSHP = fopen(pszFullname, "wb" );
-  if( fpSHP == NULL )
+  if( fpSHP == NULL ) {
+    free( pszFullname );
     return( NULL );
+  }
   
   sprintf( pszFullname, "%s.shx", pszBasename );
   fpSHX = fopen(pszFullname, "wb" );
-  if( fpSHX == NULL )
+  if( fpSHX == NULL ) {
+    free( pszFullname );
     return( NULL );
+  }
 
   free( pszFullname );
   
--- ../mapserver-5.6.0-beta1/mapsvg.c	Tue Jul 21 19:43:12 2009
+++ mapsvg.c	Mon Nov  2 13:16:36 2009
@@ -118,6 +118,7 @@ MS_DLL_EXPORT imageObj *msImageCreateSVG(int width, in
     {
         msSetError(MS_MISCERR, "web image path need to be set.",
                    "msImageCreateSVG");
+        free(image);
         return NULL;
     }
 
@@ -145,6 +146,7 @@ MS_DLL_EXPORT imageObj *msImageCreateSVG(int width, in
     {
         msSetError(MS_IOERR, "Failed to create temporary svg file.",
                     "msImageCreateSVG()" );
+        free(image);
         return NULL;
     }
 
@@ -170,6 +172,7 @@ MS_DLL_EXPORT imageObj *msImageCreateSVG(int width, in
     {
         msSetError(MS_IOERR, "Failed to open temporary svg file.",
                     "msImageCreateSVG()" );
+        free(image);
         return NULL;
     }
     
--- ../mapserver-5.6.0-beta1/mapswf.c	Mon Sep 14 23:20:29 2009
+++ mapswf.c	Mon Nov  2 13:19:31 2009
@@ -1322,6 +1322,7 @@ void msDrawStartShapeSWF(mapObj *map, layerObj *layer,
                 SWFMovie_add(GetCurrentMovie(map, image), oAction);
                 
             }
+            free(panIndex);
         }
     }
     else
@@ -3434,8 +3435,10 @@ int msDrawVectorLayerAsRasterSWF(mapObj *map, layerObj
 #endif
 
 
-    if (!image || !MS_DRIVER_SWF(image->format) )
+    if (!image || !MS_DRIVER_SWF(image->format) ) {
+      free(driver);
       return MS_FAILURE;
+    }
 
    
     if (strcasecmp(msGetOutputFormatOption(image->format,
@@ -3449,6 +3452,8 @@ int msDrawVectorLayerAsRasterSWF(mapObj *map, layerObj
     }
     else
       imagetmp = (imageObj *)((SWFObj *)image->img.swf)->imagetmp;
+
+    free(driver);
 
     if (imagetmp)
     {
--- ../mapserver-5.6.0-beta1/maptree.c	Mon Mar  9 22:04:52 2009
+++ maptree.c	Mon Nov  2 13:21:27 2009
@@ -544,8 +545,10 @@ treeNodeObj *readTreeNode( SHPTreeHandle disktree ) 
   node->ids = NULL;
 
   res = fread( &offset, 4, 1, disktree->fp );
-  if ( !res ) 
+  if ( !res ) {
+      free(node);
       return NULL;
+  }
 
   if ( disktree->needswap ) SwapWord ( 4, &offset );
    
--- ../mapserver-5.6.0-beta1/mapwmslayer.c	Fri Aug 28 23:36:25 2009
+++ mapwmslayer.c	Mon Nov  2 13:29:52 2009
@@ -966,6 +966,7 @@ int msPrepareWMSLayerRequest(int nLayerId, mapObj *map
     {
         pszProxyPassword = msDecryptStringTokens(map, pszTmp);
         if (pszProxyPassword == NULL) {
+            free(pszProxyUsername);
             return(MS_FAILURE);  /* An error should already have been produced */
         }
     }
@@ -987,6 +988,7 @@ int msPrepareWMSLayerRequest(int nLayerId, mapObj *map
         {
             msSetError(MS_WMSERR, "Invalid auth_type metadata '%s' specified",
                        "msPrepareWMSLayerRequest()", pszTmp);
+            free(pszProxyUsername);
             return MS_FAILURE;
         }
     }
@@ -1002,6 +1004,8 @@ int msPrepareWMSLayerRequest(int nLayerId, mapObj *map
     {
         pszHttpAuthPassword = msDecryptStringTokens(map, pszTmp);
         if (pszHttpAuthPassword == NULL) {
+            free(pszProxyUsername);
+            free(pszAuthUsername);
             return(MS_FAILURE);  /* An error should already have been produced */
         }
     }
@@ -1169,6 +1173,8 @@ int msPrepareWMSLayerRequest(int nLayerId, mapObj *map
             msSetError(MS_WMSERR, 
                   "WEB.IMAGEPATH must be set to use WMS client connections.",
                        "msPrepareWMSLayerRequest()");
+            free(pszProxyUsername);
+            free(pszAuthUsername);
             return MS_FAILURE;
         }
         pasReqInfo[(*numRequests)].pszHTTPCookieData = pszHTTPCookieData;
