[mapserver-commits] r11865 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Sat Jul 2 11:26:36 EDT 2011


Author: rouault
Date: 2011-07-02 08:26:36 -0700 (Sat, 02 Jul 2011)
New Revision: 11865

Modified:
   trunk/mapserver/mapimagemap.c
Log:
Prevent from accessing to ctable[256] which is invalid

Modified: trunk/mapserver/mapimagemap.c
===================================================================
--- trunk/mapserver/mapimagemap.c	2011-07-02 15:09:47 UTC (rev 11864)
+++ trunk/mapserver/mapimagemap.c	2011-07-02 15:26:36 UTC (rev 11865)
@@ -204,7 +204,6 @@
 	if (lastcolor != -1)
 		return lastcolor;
 	while (tcolor < 256 && (ctable[tcolor].r != col.red || ctable[tcolor].g != col.green || ctable[tcolor].b != col.blue)){
-		tcolor++;
 		if (abs(
 					(ctable[tcolor].r - col.red) * (ctable[tcolor].r - col.red)+ 
 					(ctable[tcolor].b - col.blue) * (ctable[tcolor].b - col.blue) + 
@@ -217,6 +216,7 @@
 					(ctable[tcolor].g - col.green) * (ctable[tcolor].g - col.green)
 				);
 		}
+        tcolor++;
 	}
 	if (tcolor >= 256) tcolor = best;
 /* DEBUG_IF	printf("%d/%d/%d (%d/%d - %d), %d : %d/%d/%d<BR>\n", ctable[tcolor].r, ctable[tcolor].g, ctable[tcolor].b, tcolor, best, delta, lastcolor, col.red, col.green, col.blue); */



More information about the mapserver-commits mailing list