Possible invalid iterator#705
Open
lucassdiass wants to merge 1 commit into
Open
Conversation
nodes pop_back could execute more than one time. In this case, iterator will be invalid in the comparison with nodes.end, so iterator must be adjusted. Signed-off-by: Lucas Dias <lucas_dias@redes.ufsm.br>
Member
|
Thanks for the PR for this delicate part of code. Please check my comment. |
Contributor
Author
|
You're welcome. Sorry, I don't understand, what's the comment for me to check? |
Contributor
Author
|
I have a question. Do you think changing the removeExpiredNode() call before line 847 makes sense? This call will remove expired nodes and free space for a new one. |
aberaud
requested changes
May 31, 2024
| return false; | ||
| // For some reason if removindNode was false, iterator could be | ||
| // invalid. | ||
| n = nodes.end(); |
Member
There was a problem hiding this comment.
With the current logic, n must always be the inserted node. If snode is inserted at the beginning of the list and the list if trimmed, n would be set to an invalid node.
Member
Yeah sorry i forgot to submit the review |
aberaud
force-pushed
the
master
branch
4 times, most recently
from
September 6, 2025 20:08
22c89fb to
122c30c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
nodes pop_back could execute more than one time.
In this case, the iterator will be invalid in the comparison with nodes.end, so iterator must be adjusted.
If the change is invalid or doesn't make sense, while loop could be replaced by an if condition