Skip to content

Commit

Permalink
Fix cleanup when DeepScanLineInputFile constructor throws
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman committed Jan 23, 2020
1 parent 801d880 commit 714a210
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions OpenEXR/IlmImf/ImfDeepScanLineInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,6 @@ DeepScanLineInputFile::DeepScanLineInputFile
:
_data (new Data (numThreads))
{
_data->_streamData = new InputStreamMutex();
_data->_deleteStream = true;
OPENEXR_IMF_INTERNAL_NAMESPACE::IStream* is = 0;

Expand All @@ -965,12 +964,29 @@ DeepScanLineInputFile::DeepScanLineInputFile
readMagicNumberAndVersionField(*is, _data->version);
//
// Backward compatibility to read multpart file.
//
// multiPartInitialize will create _streamData
if (isMultiPart(_data->version))
{
compatibilityInitialize(*is);
return;
}
}
catch (IEX_NAMESPACE::BaseExc &e)
{
if (is) delete is;
if (_data) delete _data;

REPLACE_EXC (e, "Cannot read image file "
"\"" << fileName << "\". " << e.what());
throw;
}

//
// not multiPart - allocate stream data and intialise as normal
//
try
{
_data->_streamData = new InputStreamMutex();
_data->_streamData->is = is;
_data->memoryMapped = is->isMemoryMapped();
_data->header.readFrom (*_data->_streamData->is, _data->version);
Expand Down

0 comments on commit 714a210

Please sign in to comment.