diff --git a/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx b/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx index 9b98ae39dd1..b442b951c57 100644 --- a/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx +++ b/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx @@ -2310,12 +2310,11 @@ NiftiImageIO ::Write(const void * buffer) this->m_NiftiImage->data = static_cast(nifti_buf); const int nifti_write_status = nifti_image_write_status(this->m_NiftiImage); this->m_NiftiImage->data = nullptr; // if left pointing to data buffer + delete[] nifti_buf; if (nifti_write_status) { itkExceptionMacro(<< "ERROR: nifti library failed to write image" << this->GetFileName()); } - - delete[] nifti_buf; } }