Commit e85fd37e authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

BUG: test if item is non-empty before using it

parent 3eba7347
...@@ -125,6 +125,10 @@ InputImageListParameter::GetFileNameList() const ...@@ -125,6 +125,10 @@ InputImageListParameter::GetFileNameList() const
for(InputImageParameterVectorType::const_iterator it = m_InputImageParameterVector.begin(); for(InputImageParameterVectorType::const_iterator it = m_InputImageParameterVector.begin();
it!=m_InputImageParameterVector.end();++it) it!=m_InputImageParameterVector.end();++it)
{ {
if(it->IsNull())
{
itkExceptionMacro(<< "Empty image in InputImageListParameter.");
}
filenames.push_back( (*it)->GetFileName() ); filenames.push_back( (*it)->GetFileName() );
} }
...@@ -139,7 +143,10 @@ InputImageListParameter::GetNthFileName( unsigned int i ) const ...@@ -139,7 +143,10 @@ InputImageListParameter::GetNthFileName( unsigned int i ) const
{ {
itkExceptionMacro(<< "No image "<<i<<". Only "<<m_InputImageParameterVector.size()<<" images available."); itkExceptionMacro(<< "No image "<<i<<". Only "<<m_InputImageParameterVector.size()<<" images available.");
} }
if(m_InputImageParameterVector[i].IsNull())
{
itkExceptionMacro(<< "Requested image "<<i<<" has no filename");
}
return m_InputImageParameterVector[i]->GetFileName(); return m_InputImageParameterVector[i]->GetFileName();
} }
...@@ -149,6 +156,10 @@ InputImageListParameter::GetImageList() const ...@@ -149,6 +156,10 @@ InputImageListParameter::GetImageList() const
m_ImageList->Clear(); m_ImageList->Clear();
for (unsigned int i=0 ; i < this->Size() ; ++i) for (unsigned int i=0 ; i < this->Size() ; ++i)
{ {
if(m_InputImageParameterVector[i].IsNull())
{
itkExceptionMacro(<< "Image "<<i<<" is empty.");
}
m_ImageList->PushBack(m_InputImageParameterVector[i]->GetFloatVectorImage()); m_ImageList->PushBack(m_InputImageParameterVector[i]->GetFloatVectorImage());
} }
return m_ImageList; return m_ImageList;
...@@ -161,6 +172,10 @@ InputImageListParameter::GetNthImage(unsigned int i) const ...@@ -161,6 +172,10 @@ InputImageListParameter::GetNthImage(unsigned int i) const
{ {
itkExceptionMacro(<< "No image "<<i<<". Only "<<this->Size()<<" images available."); itkExceptionMacro(<< "No image "<<i<<". Only "<<this->Size()<<" images available.");
} }
if(m_InputImageParameterVector[i].IsNull())
{
itkExceptionMacro(<< "Image "<<i<<" is empty.");
}
return m_InputImageParameterVector[i]->GetFloatVectorImage(); return m_InputImageParameterVector[i]->GetFloatVectorImage();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment