Skip to content

Commit b29dc91

Browse files
committed
BUG: Pointer to temporary variable needs resetting to null.
When the pointer to the local variable persists outside of the local function. When the local variable goes out of scope the mutable class variable should be set to nullptr.
1 parent d874496 commit b29dc91

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Modules/Registration/Metricsv4/include/itkImageToImageMetricv4.hxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@ typename ImageToImageMetricv4<TFixedImage, TMovingImage, TVirtualImage, TInterna
206206
{
207207
this->m_ComputeDerivative = false;
208208

209-
DerivativeType derivative;
210-
this->m_DerivativeResult = &derivative;
209+
DerivativeType local_derivative;
210+
this->m_DerivativeResult = &local_derivative;
211211
this->InitializeForIteration();
212212

213213
// Do the threaded processing using the appropriate
214214
// GetValueAndDerivativeThreader. Results get written to
215215
// member vars.
216216
this->GetValueAndDerivativeExecute();
217-
217+
this->m_DerivativeResult = nullptr; // Pointer to temporary local_derivative is invalid after function return
218218
return this->m_Value;
219219
}
220220

0 commit comments

Comments
 (0)