[mapserver-commits] r7901 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Tue Sep 9 10:46:49 EDT 2008


Author: dmorissette
Date: 2008-09-09 10:46:48 -0400 (Tue, 09 Sep 2008)
New Revision: 7901

Modified:
   trunk/mapserver/mapfile.c
Log:
Avoid seg fault in msFreeLabelCacheSlot if labels or markers struct members are NULL

Modified: trunk/mapserver/mapfile.c
===================================================================
--- trunk/mapserver/mapfile.c	2008-09-09 02:03:23 UTC (rev 7900)
+++ trunk/mapserver/mapfile.c	2008-09-09 14:46:48 UTC (rev 7901)
@@ -4169,7 +4169,8 @@
   int i, j;
 
   /* free the labels */
-  for(i=0; i<cacheslot->numlabels; i++) {
+  if (cacheslot->labels)
+    for(i=0; i<cacheslot->numlabels; i++) {
       msFree(cacheslot->labels[i].text);
       if (cacheslot->labels[i].labelpath)
         msFreeLabelPathObj(cacheslot->labels[i].labelpath);
@@ -4179,17 +4180,18 @@
       msFree(cacheslot->labels[i].poly); /* free's the pointer */
       for(j=0;j<cacheslot->labels[i].numstyles; j++) freeStyle(&(cacheslot->labels[i].styles[j]));
       msFree(cacheslot->labels[i].styles);
-  }
+    }
   msFree(cacheslot->labels);
   cacheslot->labels = NULL;
   cacheslot->cachesize = 0;
   cacheslot->numlabels = 0;
   
   /* free the markers */
-  for(i=0; i<cacheslot->nummarkers; i++) {
+  if (cacheslot->markers)
+    for(i=0; i<cacheslot->nummarkers; i++) {
       msFreeShape(cacheslot->markers[i].poly);
       msFree(cacheslot->markers[i].poly);
-  }
+    }
   msFree(cacheslot->markers);
   cacheslot->markers = NULL;
   cacheslot->markercachesize = 0;



More information about the mapserver-commits mailing list