Skip to content

Fix undefined behavior in Transform::ApplyToImageMetadata#6583

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
dzenanz:ubApplyTransform
Jul 10, 2026
Merged

Fix undefined behavior in Transform::ApplyToImageMetadata#6583
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
dzenanz:ubApplyTransform

Conversation

@dzenanz

@dzenanz dzenanz commented Jul 10, 2026

Copy link
Copy Markdown
Member

See B25 in issue #6575.

PR Checklist

@github-actions github-actions Bot added the area:Core Issues affecting the Core module label Jul 10, 2026
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes undefined behavior in Transform::ApplyToImageMetadata. The main change is:

  • Adds an exception when GetInverseTransform() returns null before the inverse transform is used.

Confidence Score: 5/5

Safe to merge with minimal risk.

The change is narrowly scoped to a defensive null check before the existing inverse pointer is used. No correctness or security issues were identified.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • A general-contract-validation-proof for the b25-transform path was started, and the tool/build blocker log was captured.
  • A focused code inspection log was created to record the changed-code inspection for the b25-transform path.
  • A focused harness compile attempt was logged along with harness sources to validate the build steps for the b25-transform path.
  • The harness source file for the b25-transform path was generated and saved to enable the next compilation step.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
Modules/Core/Transform/include/itkTransform.hxx Adds a null check after GetInverseTransform() in ApplyToImageMetadata so non-invertible transforms raise an ITK exception before dereferencing the inverse pointer.

Reviews (1): Last reviewed commit: "BUG: Fix possible undefined behavior in ..." | Re-trigger Greptile

@hjmjohnson
hjmjohnson merged commit c6bb0c7 into InsightSoftwareConsortium:main Jul 10, 2026
22 checks passed
@dzenanz
dzenanz deleted the ubApplyTransform branch July 13, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants