Skip to content

Commit 2f0c67f

Browse files
dzenanzkwrobot
authored andcommitted
Merge topic 'fixNullptrAccess'
b38a9f0 BUG: fixed null access found by UBSan
2 parents 1c470a6 + b38a9f0 commit 2f0c67f

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

Modules/Core/Transform/include/itkTransform.hxx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,16 @@ Transform<TParametersValueType, NInputDimensions, NOutputDimensions>
516516
::CopyInParameters(const ParametersValueType * const begin,
517517
const ParametersValueType * const end)
518518
{
519-
//Ensure that we are not copying onto self
520-
if( begin != &(this->m_Parameters[0]) )
521-
{
522-
//Copy raw values array
523-
std::copy(begin,end,this->m_Parameters.data_block() );
524-
}
519+
if ( begin == end )
520+
{
521+
return;
522+
}
523+
//Ensure that we are not copying onto self
524+
if( begin != &(this->m_Parameters[0]) )
525+
{
526+
//Copy raw values array
527+
std::copy(begin,end,this->m_Parameters.data_block() );
528+
}
525529
//Now call child class set parameter to interpret raw values
526530
this->SetParameters(this->m_Parameters);
527531
}
@@ -534,12 +538,16 @@ Transform<TParametersValueType, NInputDimensions, NOutputDimensions>
534538
::CopyInFixedParameters(const FixedParametersValueType * const begin,
535539
const FixedParametersValueType * const end)
536540
{
537-
//Ensure that we are not copying onto self
538-
if( begin != &(this->m_FixedParameters[0]) )
539-
{
540-
//Copy raw values array
541-
std::copy(begin,end,this->m_FixedParameters.data_block() );
542-
}
541+
if ( begin == end )
542+
{
543+
return;
544+
}
545+
//Ensure that we are not copying onto self
546+
if( begin != &(this->m_FixedParameters[0]) )
547+
{
548+
//Copy raw values array
549+
std::copy(begin,end,this->m_FixedParameters.data_block() );
550+
}
543551
//Now call child class set parameter to interpret raw values
544552
this->SetFixedParameters(this->m_FixedParameters);
545553
}

0 commit comments

Comments
 (0)