Skip to content

Ensure that hashing data with zero bytes avoids empty allocations and fix bridged empty data hashes from de-referencing null values #12511

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

Conversation

phausler
Copy link
Contributor

Explanation:
With the slice range fixes for data it changed the copy-out mechanism for hashing bridged data references; this caused a regression due to the fact the buffer was potentially allocated with zero bytes as well as the memcpy would be passed a null pointer from NSData for the bytes when the length was zero. This accounts for both problems and adds tests for empty Data (which worked before), empty bridged Data, and empty sliced Data (which also worked previously).

Scope:
This only applies to the hashing of empty Data objects

Radar (and possibly SR Issue):
rdar://problem/32359974

Risk:
Overall the code risk here is low since it restricts to the empty cases and allocates one byte extra of space (to avoid zero allocations).

Testing:
Additional unit tests were added to validate the correctness of this patch.

@phausler
Copy link
Contributor Author

@swift-ci please smoke test

… fix bridged empty data hashes from de-referencing null values
@phausler phausler force-pushed the swift-4.0-branch-empty_data_hashing_fix branch from c2fd97e to 007f7d2 Compare October 19, 2017 20:46
@phausler
Copy link
Contributor Author

@swift-ci please smoke test

@tkremenek tkremenek merged commit a2e34a2 into swiftlang:swift-4.0-branch Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants