Fix use of uninitialized variable in PowerupManager#5459
Merged
Alayan-stk-2 merged 3 commits intosupertuxkart:masterfrom Jun 16, 2025
Merged
Conversation
Also avoid a potenial null pointer dereference Remove two unused includes Minor cleanups
Alayan-stk-2
requested changes
Jun 15, 2025
Member
Alayan-stk-2
left a comment
There was a problem hiding this comment.
Thank you for the PR!
Please adjust the mentioned stylistic elements and it can be merged.
src/items/powerup_manager.cpp
Outdated
| { | ||
| m_num_karts = num_karts; | ||
| for (unsigned int i = 0; i < node->getNumNodes(); i++) | ||
| for (unsigned int i = 0; i < node->getNumNodes(); ++i) |
Member
There was a problem hiding this comment.
Leave i++ in loops. The vast, vast majority of loops in the STK code base use post-increment notation, so this change creates inconsistencies.
In for loops, both pre-increment and post-increment will generate exactly the same code, so this is purely a stylistic matter.
src/items/powerup_manager.cpp
Outdated
| // Keep a reference for shorter access to the list | ||
| std::vector<int> &l = m_weights_for_section.back(); | ||
| for(unsigned int i=0; i<l_string.size(); i++) | ||
| for(unsigned int j=0; j < l_string.size(); ++j) |
Member
There was a problem hiding this comment.
Same remark about ++j vs j++
Switching to j instead of i is definitely good for code clarity.
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.
Also avoid a potenial null pointer dereference
Remove two unused includes
Minor cleanups
Agreement