[mapserver-commits] r11430 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Thu Mar 31 10:12:42 EDT 2011
Author: tbonfort
Date: 2011-03-31 07:12:42 -0700 (Thu, 31 Mar 2011)
New Revision: 11430
Modified:
trunk/mapserver/maptemplate.c
Log:
check return value of fread, and close opened file case of error
Modified: trunk/mapserver/maptemplate.c
===================================================================
--- trunk/mapserver/maptemplate.c 2011-03-31 13:57:28 UTC (rev 11429)
+++ trunk/mapserver/maptemplate.c 2011-03-31 14:12:42 UTC (rev 11430)
@@ -3085,13 +3085,19 @@
if(!file) {
msSetError(MS_IOERR, "Error while allocating memory for template file.", "generateLegendTemplate()");
+ fclose(stream);
return NULL;
}
/*
* Read all the template file
*/
- fread(file, 1, length, stream);
+ if( 1 != fread(file, length, 1, stream)) {
+ msSetError(MS_IOERR, "Error while reading template file.", "generateLegendTemplate()");
+ free(file);
+ fclose(stream);
+ return NULL;
+ }
file[length] = '\0';
if(msValidateContexts(mapserv->map) != MS_SUCCESS) return NULL; /* make sure there are no recursive REQUIRES or LABELREQUIRES expressions */
More information about the mapserver-commits
mailing list