Fix temporary file removal in imdecode for tiff

The TiffDecoder keeps an open file handle.
As a consequence the file cannot be removed
before the TiffDecoder closes the file.
This commit is contained in:
Patrick Spettel
2016-08-16 10:49:11 +02:00
committed by Patrick Spettel
parent e884bbabcb
commit 84e1712659
2 changed files with 29 additions and 4 deletions
+16 -4
View File
@@ -514,8 +514,14 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
if( !decoder->readHeader() )
{
if( !filename.empty() )
remove(filename.c_str());
decoder.release();
if ( !filename.empty() )
{
if ( remove(filename.c_str()) != 0 )
{
CV_Error( CV_StsError, "unable to remove temporary file" );
}
}
return 0;
}
@@ -556,8 +562,14 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
}
bool code = decoder->readData( *data );
if( !filename.empty() )
remove(filename.c_str());
decoder.release();
if ( !filename.empty() )
{
if ( remove(filename.c_str()) != 0 )
{
CV_Error( CV_StsError, "unable to remove temporary file" );
}
}
if( !code )
{