ITK icon indicating copy to clipboard operation
ITK copied to clipboard

Do not allow mismatches in number of registration levels and number iterations array size

Open jhlegarreta opened this issue 2 years ago • 0 comments

Description

As surfaced by commit cb09ae7893267105da1d7280a87ecd1bfb9c0d20, the itk::MultiResolutionPDEDeformableRegistration class may incur a segfault if the ivar m_NumberOfLevels and the size of the m_NumberOfIterations do not match. Ideally, the class should prevent this situation by construction.

Impact analysis

The current design allows mismatches between the number of levels and the number of iterations array size (i.e. an array containing the number of iterations for each level), which can result in segfaults.

Expected behavior

The class should prevent mismatches between the number of levels and the number of iterations array size by construction. The number of levels could be deduced from the size of the m_NumberOfIterations array, and no longer be in the public interface.

Actual behavior

The actual design forces the user to set both ivars to first set the value for the m_NumberOfLevels ivar, and then set the value for the m_NumberOfIterations ivar in a such way that the size of the latter matcher the value of the former. Any other possibility is likely to result in segfaults.

Versions

master.

Additional Information

See PR #3465.

jhlegarreta avatar Jun 09 '22 00:06 jhlegarreta