Skip to content

Improve error handling in dynamic casting#903

Open
axel-grc wants to merge 2 commits intoRTKConsortium:mainfrom
axel-grc:dynamiccast
Open

Improve error handling in dynamic casting#903
axel-grc wants to merge 2 commits intoRTKConsortium:mainfrom
axel-grc:dynamiccast

Conversation

@axel-grc
Copy link
Collaborator

Close #881

dynamic_cast<rtk::FDKWarpBackProjectionImageFilter<OutputImageType, OutputImageType, DeformationType> *>(
bp.GetPointer())
->SetDeformation(def);
auto * fdkWarp =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the proposed changes too systematic. Here, it is obvious that it won't fail, it's been instantiated with this type 2 lines above. Can you go over the changes and only check the ones for which it might not work?

…d filters

- Add null checks for dynamic_cast in metadata readers (Digisens, ImagX, VarianObi, VarianProBeam, XRad) to catch malformed file data
- Add null checks for external object casts (GDCMImageIO, DOMTextNode, QuadricShape) where type isn't guaranteed at runtime
- Improves error reporting with descriptive messages instead of silent null pointer dereferences (closes RTKConsortium#881)
@axel-grc axel-grc changed the title ENH: Improve dynamic casting with error handling in various filters Improve error handling in dynamic casting Mar 11, 2026
- Move subclass-specific configuration into switch cases where concrete type is known
- Eliminates unsafe dynamic_cast in rtkbackprojections, rtkforwardprojections, and factory methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check all dynamic_cast for 0 value to avoid segmentation faults

2 participants