-
Notifications
You must be signed in to change notification settings - Fork 100
Fix memory leak from repeated ProjDataInfo::clone() calls #1673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Based on CODACY suggestion I simplified a bit the set_template_proj_data_info() to use the shared_ptr |
KrisThielemans
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have flagged some minor style issues. In addition, it'd be best to add an overload for backwards compatibility.
void set_template_proj_data_info(const ProjDataInfo&);
which would then have to do the clone and call the other one, e.g.
set_template_proj_data_info(arg.make_shared_clone());
It's possible that you'd have to %ignore the new one in SWIG though.
| write_to_file("image_with_voxel_at_30_0", *image1_sptr); | ||
|
|
||
| image = *image.get_empty_copy(); | ||
| image.fill(0); //= *image.get_empty_copy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this one
|
@NikEfth can we get this one across the line? |
All set :) |
KrisThielemans
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final clean-up, please. I guess I'll squash merge this then, if that's alright for you.
| write_to_file("image_with_voxel_at_30_0", *image1_sptr); | ||
|
|
||
| image = *image.get_empty_copy(); | ||
| image.fill(0); //= *image.get_empty_copy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this one
|
all set |
KrisThielemans
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great. thanks. I forgot to ask to add a line or 2 in release_6.4.htm. I guess in the section bug fixes. sorry
|
appveyor builds were failing due to GitHub being unstable (also the webserver). |
|
Done |
|
ah, conflict. can you merge |
Co-authored-by: Kris Thielemans <KrisThielemans@users.noreply.github.com>
Co-authored-by: Kris Thielemans <KrisThielemans@users.noreply.github.com>
Co-authored-by: Kris Thielemans <KrisThielemans@users.noreply.github.com>
…template projection data info using a ProjDataInfo object directly, instead of only through a shared pointer. This new method creates a shared pointer from the given ProjDataInfo object and then calls the existing method that takes a shared pointer.
a9a82cf to
c32e562
Compare
|
Can you check that everything is fine? I had problems with rebase ... |
|
That's the main reason why I try to avoid I have no obvious way to check if this is still correct due to
I have no obvious way to trigger the checks, so I suggest you force-push again after editing the last commit message ( |
This PR fixes a memory leak detected by AddressSanitizer in ScatterSimulation::set_template_proj_data_info.
The issue was caused by calling arg.clone() multiple times inside dynamic_cast expressions, leading to leaked heap allocations when the cast failed.
The fix:
• Calls clone() exactly once
• Transfers ownership safely using a smart pointer
• Preserves the existing runtime type checks for supported ProjDataInfo types
This change is purely a memory-safety fix and does not alter behaviour or interfaces.
Changes in this pull request
Testing performed
Related issues
Checklist before requesting a review
documentation/release_XXX.mdhas been updated with any functionality change (if applicable)Contribution Notes
Please tick the following: