Skip to content

[stdlib] tolerate empty source buffers in UMRBP.copyMemory #41836

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 2 commits into from
Mar 16, 2022

Conversation

glessard
Copy link
Contributor

@glessard glessard commented Mar 16, 2022

The implementation previously trapped when the source buffer was empty and the source's baseAddress was nil. That behaviour is neither documented nor necessary. The real precondition is that the source buffer cannot be larger than the destination. When the source buffer is empty, that precondition is necessarily met.

This updated version of UnsafeMutableRawBufferPointer.copyMemory simply returns when the source buffer is empty.

Resolves SR-15994 (rdar://90350360).

- The previous implementation trapped when the source buffer was empty. That behaviour is both not documented and unnecessary. If the source buffer is empty, its length is necessarily shorter or equal than the length of the destination.
- The updated version simply returns when the source buffer is empty.
@glessard
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@glessard
Copy link
Contributor Author

@swift-ci please smoke test macOS platform

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.

3 participants