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

Modernize buffer access #71

Merged
merged 1 commit into from
Nov 6, 2020
Merged

Modernize buffer access #71

merged 1 commit into from
Nov 6, 2020

Conversation

1ec5
Copy link
Collaborator

@1ec5 1ec5 commented Nov 6, 2020

#43 fixed a Swift compiler warning about unsafely casting a buffer in memory by reinterpreting the data as an NSData, which has fewer safety checks. We got lucky until adding support for Linux in #55: on some systems, the string is stored in a format that’s inconsistent with NSData’s internal storage on Apple platforms. This resulted in undefined behavior and random crashes on Linux when calling decodePolyline(_:precision:). As of Swift 5, the safer way to get random access into this buffer appears to be Data.withUnsafeBytes(_:) and casting later.

/cc @frederoni @MaximAlien @erichoracek

@1ec5 1ec5 added the bug label Nov 6, 2020
@1ec5 1ec5 self-assigned this Nov 6, 2020
@1ec5 1ec5 mentioned this pull request Nov 6, 2020
6 tasks
@1ec5
Copy link
Collaborator Author

1ec5 commented Nov 6, 2020

The PR build succeeded about 10 minutes ago, but GitHub hasn’t been notified yet.

@1ec5 1ec5 merged commit 0cd4499 into master Nov 6, 2020
@1ec5 1ec5 deleted the 1ec5-mapbox-directions-tests branch November 6, 2020 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant