[mapserver-commits] r8635 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Thu Mar 5 16:39:21 EST 2009


Author: assefa
Date: 2009-03-05 16:39:21 -0500 (Thu, 05 Mar 2009)
New Revision: 8635

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapogcsld.c
Log:
SLD: Correct crash with large class names (#2915)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2009-03-05 20:42:03 UTC (rev 8634)
+++ trunk/mapserver/HISTORY.TXT	2009-03-05 21:39:21 UTC (rev 8635)
@@ -12,6 +12,8 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- SLD: Correct crash with large class names (#2915)
+
 - Added Java MapScript WIN64 support (#2250)
 
 - Fixed a problem with long running processes, embedded scalebars/legends and AGG. (#2887)

Modified: trunk/mapserver/mapogcsld.c
===================================================================
--- trunk/mapserver/mapogcsld.c	2009-03-05 20:42:03 UTC (rev 8634)
+++ trunk/mapserver/mapogcsld.c	2009-03-05 21:39:21 UTC (rev 8635)
@@ -4233,6 +4233,7 @@
 
 #ifdef USE_OGR
     char szTmp[100];
+    char *pszTmpName = NULL;
     int i, j;
     styleObj *psStyle = NULL;
     char *pszFilter = NULL;
@@ -4267,12 +4268,18 @@
         else if (psLayer->name)
         {
             pszEncoded = msEncodeHTMLEntities(psLayer->name);
+            pszTmpName = (char *)malloc(sizeof(char)*(strlen(pszEncoded)+100));
             if (nVersion > OWS_1_0_0)
-              sprintf(szTmp, "<se:Name>%s</se:Name>\n", pszEncoded);
+              sprintf(pszTmpName, "<se:Name>%s</se:Name>\n", pszEncoded);
             else
-              sprintf(szTmp, "<Name>%s</Name>\n", pszEncoded);
+              sprintf(pszTmpName, "<Name>%s</Name>\n", pszEncoded);
+            
+            
+            msFree(pszEncoded);
+            pszFinalSLD = msStringConcatenate(pszFinalSLD, szTmp);
+            msFree(pszTmpName);
+            pszTmpName=NULL;
 
-            msFree(pszEncoded);
         }
         else
         {
@@ -4280,8 +4287,9 @@
               sprintf(szTmp, "<se:Name>%s</se:Name>\n", "NamedLayer");
             else
               sprintf(szTmp, "<Name>%s</Name>\n", "NamedLayer"); 
+            pszFinalSLD = msStringConcatenate(pszFinalSLD, szTmp);
         }
-        pszFinalSLD = msStringConcatenate(pszFinalSLD, szTmp);
+        
 
         sprintf(szTmp, "%s\n",  "<UserStyle>");
         pszFinalSLD = msStringConcatenate(pszFinalSLD, szTmp);
@@ -4311,16 +4319,19 @@
                 if (psLayer->class[i]->name)
                 {
                     pszEncoded = msEncodeHTMLEntities(psLayer->class[i]->name);
-                    
+                    pszTmpName = (char *)malloc(sizeof(char)*(strlen(pszEncoded)+100));
+
                     if (nVersion > OWS_1_0_0)
-                      sprintf(szTmp, "<se:Name>%s</se:Name>\n",  pszEncoded);
+                      sprintf(pszTmpName, "<se:Name>%s</se:Name>\n",  pszEncoded);
                     else
-                      sprintf(szTmp, "<Name>%s</Name>\n",  pszEncoded);
+                      sprintf(pszTmpName, "<Name>%s</Name>\n",  pszEncoded);
 
                     msFree(pszEncoded);
 
-                    pszFinalSLD = msStringConcatenate(pszFinalSLD, szTmp);
-                }
+                    pszFinalSLD = msStringConcatenate(pszFinalSLD, pszTmpName);
+                    msFree(pszTmpName);
+                    pszTmpName=NULL;
+               }
 /* -------------------------------------------------------------------- */
 /*      get the Filter if there is a class expression.                  */
 /* -------------------------------------------------------------------- */



More information about the mapserver-commits mailing list