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

[3.x] Core: Add recursion level check for Array and Dictionary hashing #80888

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Aug 22, 2023

It also prevents crashes in cases like:

var a = []
a.append(a)
print(a.hash())

@dalexeev dalexeev added bug topic:core crash cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release labels Aug 22, 2023
@dalexeev dalexeev added this to the 3.6 milestone Aug 22, 2023
@dalexeev dalexeev requested a review from a team as a code owner August 22, 2023 12:20
@dalexeev dalexeev linked an issue Aug 22, 2023 that may be closed by this pull request
return recursive_hash(0);
}

uint32_t Array::recursive_hash(int p_recursion_count) const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me suggest declaring these as (private) uint32_t T::_hash(int p_recursion_count = 0) const.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I just copied it from 4.x though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, if the one in 4.x is already merged, just feel free to ignore me (or make a PR for 4.x if you think my suggestion has enough merit).

@akien-mga akien-mga merged commit fcaf4c7 into godotengine:3.x Aug 28, 2023
13 checks passed
@akien-mga
Copy link
Member

Thanks!

@dalexeev dalexeev deleted the 3.x-core-array-and-dictionary-recursive-hash branch August 28, 2023 10:02
@akien-mga
Copy link
Member

Cherry-picked for 3.5.3.

@akien-mga akien-mga removed the cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release label Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[3.x] Using Dictionary as own key crashes Godot
3 participants