Skip to content

Commit 8505c1a

Browse files
authored
Merge pull request #6064 from hjmjohnson/backport-ipl-null-checks
BUG: Backport null checks after ReadHeader in IPLCommonImageIO
2 parents f9a2e13 + b5b3b0a commit 8505c1a

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Modules/IO/IPL/src/itkIPLCommonImageIO.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@ IPLCommonImageIO::ReadImageInformation()
133133
FileNameToRead = _imagePath;
134134

135135
this->m_ImageHeader = this->ReadHeader(FileNameToRead.c_str());
136-
//
137-
// if anything fails in the header read, just let
138-
// exceptions propagate up.
136+
if (m_ImageHeader == nullptr)
137+
{
138+
itkExceptionMacro("ReadHeader failed for " << FileNameToRead);
139+
}
139140

140141
bool isCT = false;
141142
std::string modality = m_ImageHeader->modality;
@@ -224,6 +225,10 @@ IPLCommonImageIO::ReadImageInformation()
224225
// throw an exception, and we'd just want to skip it.
225226
continue;
226227
}
228+
if (curImageHeader == nullptr)
229+
{
230+
itkExceptionMacro("ReadHeader failed for " << fullPath);
231+
}
227232
if ((((isCT) ? curImageHeader->examNumber : curImageHeader->echoNumber) == m_FilenameList->GetKey2()) &&
228233
(curImageHeader->seriesNumber == m_FilenameList->GetKey1()))
229234
{

0 commit comments

Comments
 (0)