Skip to content

Commit

Permalink
fix potential io streams leak in case of exceptions during 'initializ…
Browse files Browse the repository at this point in the history
…e' function
  • Loading branch information
CAHEK7 authored and nickrasmussen committed Aug 8, 2018
1 parent 60cc8b7 commit 19bac86
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions OpenEXR/IlmImf/ImfDeepScanLineOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ DeepScanLineOutputFile::DeepScanLineOutputFile
}
catch (IEX_NAMESPACE::BaseExc &e)
{
delete _data->_streamData->os;
delete _data->_streamData;
delete _data;

Expand All @@ -845,6 +846,7 @@ DeepScanLineOutputFile::DeepScanLineOutputFile
}
catch (...)
{
delete _data->_streamData->os;
delete _data->_streamData;
delete _data;
throw;
Expand Down
2 changes: 2 additions & 0 deletions OpenEXR/IlmImf/ImfMultiPartInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ MultiPartInputFile::MultiPartInputFile(const char fileName[],
}
catch (IEX_NAMESPACE::BaseExc &e)
{
delete _data->is;
delete _data;

REPLACE_EXC (e, "Cannot read image file "
Expand All @@ -145,6 +146,7 @@ MultiPartInputFile::MultiPartInputFile(const char fileName[],
}
catch (...)
{
delete _data->is;
delete _data;
throw;
}
Expand Down
2 changes: 2 additions & 0 deletions OpenEXR/IlmImf/ImfMultiPartOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ MultiPartOutputFile::MultiPartOutputFile (const char fileName[],
}
catch (IEX_NAMESPACE::BaseExc &e)
{
delete _data->os;
delete _data;

REPLACE_EXC (e, "Cannot open image file "
Expand All @@ -234,6 +235,7 @@ MultiPartOutputFile::MultiPartOutputFile (const char fileName[],
}
catch (...)
{
delete _data->os;
delete _data;
throw;
}
Expand Down
10 changes: 6 additions & 4 deletions OpenEXR/IlmImf/ImfOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,17 +678,19 @@ OutputFile::OutputFile
}
catch (IEX_NAMESPACE::BaseExc &e)
{
if (_data && _data->_streamData) delete _data->_streamData;
if (_data) delete _data;
delete _data->_streamData->os;
delete _data->_streamData;
delete _data;

REPLACE_EXC (e, "Cannot open image file "
"\"" << fileName << "\". " << e);
throw;
}
catch (...)
{
if (_data && _data->_streamData) delete _data->_streamData;
if (_data) delete _data;
delete _data->_streamData->os;
delete _data->_streamData;
delete _data;

throw;
}
Expand Down
2 changes: 2 additions & 0 deletions OpenEXR/IlmImf/ImfTiledOutputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ TiledOutputFile::TiledOutputFile
}
catch (IEX_NAMESPACE::BaseExc &e)
{
delete _streamData->os;
delete _streamData;
delete _data;

Expand All @@ -885,6 +886,7 @@ TiledOutputFile::TiledOutputFile
}
catch (...)
{
delete _streamData->os;
delete _streamData;
delete _data;
throw;
Expand Down

0 comments on commit 19bac86

Please sign in to comment.