Skip to content
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

fix: remove pointer to loop variable when searching the latest event to analyze #328

Merged

Conversation

patrickpichler
Copy link
Contributor

📑 Description

Having a pointer to a range variable will always yield the latest value the loop sees. This leads to subtle bugs. To prevent this from happening, the range variable was assigned to a temp variable, which is then referenced as a pointer.

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

…to analyze

Having a pointer to a range variable will always yield the latest value
the loop sees. This leads to subtle bugs. To prevent this from
happening, the range variable was assigned to a temp variable, which is
then referenced as a pointer.

Signed-off-by: Patrick Pichler <git@patrickpichler.dev>
@patrickpichler patrickpichler requested review from a team as code owners April 25, 2023 09:02
@AlexsJones AlexsJones merged commit 2616220 into k8sgpt-ai:main Apr 25, 2023
patrickpichler added a commit to patrickpichler/k8sgpt that referenced this pull request Apr 25, 2023
…to analyze (k8sgpt-ai#328)

Having a pointer to a range variable will always yield the latest value
the loop sees. This leads to subtle bugs. To prevent this from
happening, the range variable was assigned to a temp variable, which is
then referenced as a pointer.

Signed-off-by: Patrick Pichler <git@patrickpichler.dev>
Co-authored-by: Patrick Pichler <git@patrickpichler.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants