Permalink
Browse files

Fix missing fcloses on failures (#5143)

  • Loading branch information...
gogglesguy authored and tbonfort committed Aug 19, 2015
1 parent 75d092a commit de2869bcd8586f618aa4f2078088dc82b3e9136a
Showing with 7 additions and 0 deletions.
  1. +3 −0 mapimageio.c
  2. +1 −0 mapjoin.c
  3. +1 −0 mapshape.c
  4. +2 −0 mapv8.cpp
View
@@ -391,11 +391,13 @@ int readPalette(const char *palette, rgbaPixel *entries, unsigned int *nEntries,
continue; /* skip comments and blank lines */
if(!useAlpha) {
if(3 != sscanf(buffer,"%d,%d,%d\n",&r,&g,&b)) {
fclose(stream);
msSetError(MS_MISCERR,"failed to parse color %d r,g,b triplet in line \"%s\" from file %s","readPalette()",*nEntries+1,buffer,palette);
return MS_FAILURE;
}
} else {
if(4 != sscanf(buffer,"%d,%d,%d,%d\n",&r,&g,&b,&a)) {
fclose(stream);
msSetError(MS_MISCERR,"failed to parse color %d r,g,b,a quadruplet in line \"%s\" from file %s","readPalette()",*nEntries+1,buffer,palette);
return MS_FAILURE;
}
@@ -1090,6 +1092,7 @@ int msLoadMSRasterBufferFromFile(char *path, rasterBufferObj *rb)
return MS_FAILURE;
}
if(1 != fread(signature,8,1,stream)) {
fclose(stream);
msSetError(MS_MISCERR, "Unable to read header from image file %s", "msLoadMSRasterBufferFromFile()",path);
return MS_FAILURE;
}
View
@@ -362,6 +362,7 @@ int msCSVJoinConnect(layerObj *layer, joinObj *join)
rewind(stream);
if((joininfo->rows = (char ***) malloc(joininfo->numrows*sizeof(char **))) == NULL) {
fclose(stream);
msSetError(MS_MEMERR, "Error allocating rows.", "msCSVJoinConnect()");
return(MS_FAILURE);
}
View
@@ -268,6 +268,7 @@ SHPHandle msSHPOpen( const char * pszLayer, const char * pszAccess )
psSHP->fpSHX = fopen(pszFullname, pszAccess );
}
if( psSHP->fpSHX == NULL ) {
fclose(psSHP->fpSHP);
msFree(pszBasename);
msFree(pszFullname);
msFree(psSHP);
View
@@ -92,6 +92,8 @@ static Handle<Value> msV8ReadFile(V8Context *v8context, const char *path)
for (int i = 0; i < size;) {
int read = static_cast<int>(fread(&chars[i], 1, size - i, file));
if (read == 0) {
delete [] chars;
fclose(file);
msDebug("msV8ReadFile: error while reading file '%s'\n", path);
return Undefined();
}

0 comments on commit de2869b

Please sign in to comment.