From 3422b344f6189e499fe4c00f11491843a23d24a4 Mon Sep 17 00:00:00 2001 From: peterhillman Date: Sat, 8 Feb 2020 17:14:09 +1300 Subject: [PATCH] fix crash with damaged EXR files (#656) Signed-off-by: Peter Hillman --- OpenEXR/IlmImf/ImfScanLineInputFile.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/OpenEXR/IlmImf/ImfScanLineInputFile.cpp b/OpenEXR/IlmImf/ImfScanLineInputFile.cpp index 5656c45d3e..1ef4eba3f4 100644 --- a/OpenEXR/IlmImf/ImfScanLineInputFile.cpp +++ b/OpenEXR/IlmImf/ImfScanLineInputFile.cpp @@ -1181,8 +1181,11 @@ ScanLineInputFile::ScanLineInputFile(InputPartData* part) { for (size_t i = 0; i < _data->lineBuffers.size(); i++) { - EXRFreeAligned(_data->lineBuffers[i]->buffer); - _data->lineBuffers[i]->buffer=nullptr; + if( _data->lineBuffers[i] ) + { + EXRFreeAligned(_data->lineBuffers[i]->buffer); + _data->lineBuffers[i]->buffer=nullptr; + } } } @@ -1234,11 +1237,14 @@ ScanLineInputFile::ScanLineInputFile { if (!_data->memoryMapped) { - for (size_t i = 0; i < _data->lineBuffers.size(); i++) - { - EXRFreeAligned(_data->lineBuffers[i]->buffer); - _data->lineBuffers[i]->buffer=nullptr; - } + for (size_t i = 0; i < _data->lineBuffers.size(); i++) + { + if( _data->lineBuffers[i] ) + { + EXRFreeAligned(_data->lineBuffers[i]->buffer); + _data->lineBuffers[i]->buffer=nullptr; + } + } } } delete _streamData;