[mapserver-commits] r7524 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Thu Apr 17 13:37:35 EDT 2008
Author: sdlime
Date: 2008-04-17 13:37:35 -0400 (Thu, 17 Apr 2008)
New Revision: 7524
Modified:
trunk/mapserver/mapgd.c
Log:
Avoid segfault associated with not finding a palette file. (bug 2577)
Modified: trunk/mapserver/mapgd.c
===================================================================
--- trunk/mapserver/mapgd.c 2008-04-16 12:18:56 UTC (rev 7523)
+++ trunk/mapserver/mapgd.c 2008-04-17 17:37:35 UTC (rev 7524)
@@ -3561,10 +3561,10 @@
}
#ifdef USE_RGBA_PNG
if( format->imagemode == MS_IMAGEMODE_RGBA ) {
- if( force_palette )
- return msSaveImageRGBAPalette(img, ctx ,format);
- else if( force_pc256 )
- return msSaveImageRGBAQuantized(img, ctx ,format);
+ if( force_palette )
+ return msSaveImageRGBAPalette(img, ctx ,format);
+ else if( force_pc256 )
+ return msSaveImageRGBAQuantized(img, ctx ,format);
}
#endif /*USE_RGBA_PNG*/
if( force_palette ) {
@@ -3572,11 +3572,14 @@
int method=0;
const char *palette = msGetOutputFormatOption( format, "PALETTE", "palette.txt");
const char *palette_method = msGetOutputFormatOption( format, "PALETTE_MEM", "0");
+
gdPImg = msImageCreateWithPaletteGD(img, palette, gdImageSX(img), gdImageSY(img));
+ if(!gdPImg) return MS_FAILURE; /* most likely a bad palette */
+
if(strcasecmp(palette_method,"conservative")==0)
- method=1;
+ method=1;
else if(strcasecmp(palette_method,"liberal")==0)
- method=2;
+ method=2;
msImageCopyForcePaletteGD(img, gdPImg, method);
gdImagePngCtx(gdPImg, ctx);
@@ -3685,6 +3688,8 @@
method=2;
gdPImg = msImageCreateWithPaletteGD(img, palette, gdImageSX(img), gdImageSY(img));
+ if(!gdPImg) return NULL; /* most likely a bad palette */
+
msImageCopyForcePaletteGD(img, gdPImg, method);
imgbytes = gdImagePngPtr(gdPImg, size_ptr);
gdImageDestroy(gdPImg);
More information about the mapserver-commits
mailing list