Opened 20 years ago

Closed 20 years ago

#522 closed defect (fixed)

Wrong check on error code in maptemplate.c / msGenerateImages()

Reported by: frank.koormann@… Owned by: dmorissette
Priority: high Milestone:
Component: MapServer CGI Version: 4.0
Severity: normal Keywords:
Cc:

Description

The maputil.c / msSaveImage() function returns one of 
enum MS_RETURN_VALUE {MS_SUCCESS, MS_FAILURE, MS_DONE}
to report the status. 

However, in maptemplate.c / msGenerateImages() the return_code checked for 
equality to -1. This should be compared against MS_SUCCESS. See the patch below.

This bug holds for both, 4.0 and 4.1. I found it within a CGI test app with
extensive use of relational path names. I wondered that reference, scalebar and
legend haven't been rendered, although the processed template references them
with correct names and the mapserv CGI terminates with success. Applying a bug
you get an error, so maybe the fix reduces the frequent mystic problems reported
on the mailing lists.

Cheers,
  Frank


--- mapserver-4.0.1.orig/maptemplate.c	Fri Aug  1 06:30:16 2003
+++ mapserver-4.0.1/maptemplate.c	Wed Dec 17 19:28:09 2003
@@ -845,7 +845,7 @@
          }
          
          // save it with a unique file name
-         if(msSaveImage(map, img, pszFullImgFname) == -1) {
+         if(msSaveImage(map, img, pszFullImgFname) != MS_SUCCESS) {
             if (myHashTable)
               msFreeHashTable(myHashTable);
 
@@ -2658,7 +2658,7 @@
                         msObj->Map->name, msObj->Id, 
                         MS_IMAGE_EXTENSION(msObj->Map->outputformat));	
 
-                if (msSaveImage(msObj->Map, image, buffer) == -1 &&
+                if (msSaveImage(msObj->Map, image, buffer) != MS_SUCCESS &&
                     bReturnOnError)
                 {
                     msFreeImage(image);
@@ -2683,7 +2683,7 @@
                         msObj->Map->name, msObj->Id, 
                         MS_IMAGE_EXTENSION(msObj->Map->outputformat));
                 
-                if (msSaveImage(NULL, image, buffer) == -1 &&
+                if (msSaveImage(NULL, image, buffer) != MS_SUCCESS &&
                     bReturnOnError)
                 {
                     msFreeImage(image);
@@ -2707,7 +2707,7 @@
                 sprintf(buffer, "%s%ssb%s.%s", msObj->Map->web.imagepath, 
                         msObj->Map->name, msObj->Id, 
                         MS_IMAGE_EXTENSION(msObj->Map->outputformat));
-                if (msSaveImage(NULL, image, buffer) == -1 &&
+                if (msSaveImage(NULL, image, buffer) != MS_SUCCESS &&
                     bReturnOnError)
                 {
                     msFreeImage(image);
@@ -2731,7 +2731,7 @@
                 sprintf(buffer, "%s%sref%s.%s", msObj->Map->web.imagepath, 
                         msObj->Map->name, msObj->Id, 
                         MS_IMAGE_EXTENSION(msObj->Map->outputformat));
-                if (msSaveImage(NULL, image, buffer) == -1 &&
+                if (msSaveImage(NULL, image, buffer) != MS_SUCCESS &&
                     bReturnOnError)
                 {
                     msFreeImage(image);

Attachments (1)

mapserver-4.0-msSaveImage_ReturnCode.patch (2.1 KB ) - added by frank.koormann@… 20 years ago.
maptemplate.c / msGenerateImages(): msSaveImage_ReturnCode.patch

Download all attachments as: .zip

Change History (3)

by frank.koormann@…, 20 years ago

maptemplate.c / msGenerateImages(): msSaveImage_ReturnCode.patch

comment:1 by dmorissette, 20 years ago

Cc: steve.lime@… added
Owner: changed from sdlime to morissette@…
Taking this one.

comment:2 by dmorissette, 20 years ago

Resolution: fixed
Status: newclosed
Fixed.  Thanks for the patch, I applied it to the 4.1 CVS.
Note: See TracTickets for help on using tickets.