8000 Reduce HT_MAX_SIZE to account for the max load factor of 0.5 by arnaud-lb · Pull Request #10242 · php/php-src · GitHub
[go: up one dir, main page]

Skip to content

Reduce HT_MAX_SIZE to account for the max load factor of 0.5 #10242

8000
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

Merged
merged 3 commits into from
Jan 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Avoid overflow when nTableMask is (uint32_t)INT32_MAX+1
  • Loading branch information
arnaud-lb committed Jan 7, 2023
commit 1772783a6f435795d6c2cdc31ad1e0167d5de9c8
2 changes: 1 addition & 1 deletion Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ struct _zend_array {
#define HT_SIZE_TO_MASK(nTableSize) \
((uint32_t)(-((nTableSize) + (nTableSize))))
#define HT_HASH_SIZE(nTableMask) \
(((size_t)(uint32_t)-(int32_t)(nTableMask)) * sizeof(uint32_t))
(((size_t)-(uint32_t)(nTableMask)) * sizeof(uint32_t))
Comment on lines -431 to +438
Copy link
Member Author

Choose a reason for hiding this comment

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

(int32_t)(nTableMask) is implementation defined when nTableMask has its max value (uint32_t)INT32_MAX+1.

I think that the (int32_t) cast is not necessary here, and that -(uint32_t)(nTableMask) gives the same result without being implementation defined.

#define HT_DATA_SIZE(nTableSize) \
((size_t)(nTableSize) * sizeof(Bucket))
#define HT_SIZE_EX(nTableSize, nTableMask) \
Expand Down
0