Repository navigation
fix(swift): unwrap baseAddress before memcpy in WriteBuffer.append(UnsafeRawBufferPointer) - #3762
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
…safeRawBufferPointer) On Linux, glibc declares memcpy's source parameter as nonnull, so passing the optional UnsafeRawBufferPointer.baseAddress fails to compile.
oldergod
approved these changes
Nov 12, 2026
oldergod
left a comment
Member
There was a problem hiding this comment.
Please sign the Square Contributor License Agreement before this merges: https://docs.google.com/forms/d/e/1FAIpQLSeRVQ35-gq2vdSxD1kdh7CJwRdjmUA0EZ9gRXaWYoUeKPZEQQ/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1. I could not find your GitHub user name on the list of signers.
Author
|
Thanks for approving this! Whenever you have a moment, it should be ready to merge (CI is green). Happy to rebase or adjust anything if needed. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3757
Cause:
WriteBuffer.append(_ value: UnsafeRawBufferPointer)passesvalue.baseAddress(anUnsafeRawPointer?) straight tomemcpy. On Darwin the parameter is nullable, but glibc declares it nonnull, so the Swift runtime does not compile on Linux (Swift 6.2, Ubuntu 24.04).Fix: bind
baseAddressin the existingguard(empty buffers still return early) and pass the unwrapped pointer.Test: added
WriteBufferTests.testAppendRawBufferPointer(non-empty and empty/nil-base buffers).swift build --target Wireinswift:6.2fails before the change with the error from the issue and succeeds after. The XCTest target itself does not build on Linux in this setup, so the new test was not run.This PR was prepared with the assistance of an AI coding agent (Claude) and submitted by a human contributor who is responsible for it.