-
Notifications
You must be signed in to change notification settings - Fork 24
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
Rm #945
base: master
Are you sure you want to change the base?
Rm #945
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -41,6 +41,10 @@ namespace solver | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
virtual void initialize(level_t& /*level*/) override {} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
virtual amr::IResourcesManager& resources_manager() const override | ||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||
return *std::dynamic_pointer_cast<amr::IResourcesManager>(resourcesManager); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
Comment on lines
+44
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for dynamic_pointer_cast. The dynamic_pointer_cast could fail at runtime. Consider adding error handling to prevent undefined behavior. virtual amr::IResourcesManager& resources_manager() const override
{
- return *std::dynamic_pointer_cast<amr::IResourcesManager>(resourcesManager);
+ auto castedManager = std::dynamic_pointer_cast<amr::IResourcesManager>(resourcesManager);
+ if (!castedManager) {
+ throw std::runtime_error("Failed to cast resourcesManager to IResourcesManager");
+ }
+ return *castedManager;
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
virtual void allocate(patch_t& patch, double const allocateTime) override | ||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||
|
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.
Add null pointer check in resources_manager method.
The dynamic pointer cast could return nullptr if the cast fails.
Apply this diff to add null pointer validation:
📝 Committable suggestion