Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
ffi: Move
SchemaTreeNode
intoSchemaTree
; Use anoptional
for the parent ID in the schema tree node to track nodes which have no parents (the root). #554ffi: Move
SchemaTreeNode
intoSchemaTree
; Use anoptional
for the parent ID in the schema tree node to track nodes which have no parents (the root). #554Changes from 8 commits
287ddeb
8a70a07
292ac9e
e1b94c7
eee2b76
a82ed4f
081405f
4048734
4021865
7cad744
07be6c3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Potential null dereference when accessing parent node in
insert_node
In the
insert_node
method, you accesslocator.get_parent_id()
without checking if it has a value:Since
locator.get_parent_id()
can now bestd::nullopt
for the root node, accessingm_tree_nodes[locator.get_parent_id()]
without checking may lead to undefined behaviour.Consider checking whether
locator.get_parent_id()
has a value before accessingm_tree_nodes[locator.get_parent_id().value()]
.Apply this diff to fix the issue:
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.
🛠️ Refactor suggestion
Consistent handling of optional parent IDs
In the
revert
method, you correctly check ifnode.get_parent_id()
has a value before accessing it:Consider applying the same pattern in other methods, such as
insert_node
andtry_get_node_id
, to ensure consistent and safe handling of optional parent IDs throughout the codebase.