diff --git a/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx b/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx index b0698c00e55..858e6a7f0d7 100644 --- a/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx +++ b/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx @@ -133,9 +133,10 @@ IPLCommonImageIO::ReadImageInformation() FileNameToRead = _imagePath; this->m_ImageHeader = this->ReadHeader(FileNameToRead.c_str()); - // - // if anything fails in the header read, just let - // exceptions propagate up. + if (m_ImageHeader == nullptr) + { + itkExceptionMacro("ReadHeader failed for " << FileNameToRead); + } bool isCT = false; std::string modality = m_ImageHeader->modality; @@ -224,6 +225,10 @@ IPLCommonImageIO::ReadImageInformation() // throw an exception, and we'd just want to skip it. continue; } + if (curImageHeader == nullptr) + { + itkExceptionMacro("ReadHeader failed for " << fullPath); + } if ((((isCT) ? curImageHeader->examNumber : curImageHeader->echoNumber) == m_FilenameList->GetKey2()) && (curImageHeader->seriesNumber == m_FilenameList->GetKey1())) {