close outfile on error

pull/2077/head
Isaac Connor 2017-12-12 13:18:57 -05:00
parent 47f3971f9a
commit 46094fe6cf
1 changed files with 7 additions and 9 deletions

View File

@ -779,24 +779,22 @@ bool Image::ReadRaw( const char *filename )
return( true );
}
bool Image::WriteRaw( const char *filename ) const
{
bool Image::WriteRaw( const char *filename ) const {
FILE *outfile;
if ( (outfile = fopen( filename, "wb" )) == NULL )
{
if ( (outfile = fopen( filename, "wb" )) == NULL ) {
Error( "Can't open %s: %s", filename, strerror(errno) );
return( false );
return false;
}
if ( fwrite( buffer, size, 1, outfile ) != 1 )
{
if ( fwrite( buffer, size, 1, outfile ) != 1 ) {
Error( "Unable to write to '%s': %s", filename, strerror(errno) );
return( false );
fclose( outfile );
return false;
}
fclose( outfile );
return( true );
return true;
}
bool Image::ReadJpeg( const char *filename, unsigned int p_colours, unsigned int p_subpixelorder)