Skip to content

Commit

Permalink
BUG: move null check to *before* dereferencing
Browse files Browse the repository at this point in the history
cppcheck warned:

nullPointerRedundantCheck,itkTimeVaryingVelocityFieldIntegrationImageFilter.hxx:67,warning,Either the condition '!input' is redundant or there is possible null pointer dereference: input.

There is a slight behaviour change now: `m_NumberOfTimePoints` is no longer set if `input` is provided and `output` is not.
  • Loading branch information
seanm authored and N-Dekker committed Jan 7, 2025
1 parent 9207a7c commit 5c8b2d8
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ TimeVaryingVelocityFieldIntegrationImageFilter<TTimeVaryingVelocityField,
{
const TimeVaryingVelocityFieldType * input = this->GetInput();
DisplacementFieldType * output = this->GetOutput();
this->m_NumberOfTimePoints = input->GetLargestPossibleRegion().GetSize()[OutputImageDimension];
if (!input || !output)
{
return;
}
this->m_NumberOfTimePoints = input->GetLargestPossibleRegion().GetSize()[OutputImageDimension];

//
// The ImageBase::CopyInformation() method ca not be used here
Expand Down

0 comments on commit 5c8b2d8

Please sign in to comment.