Commit 96cf7f5
Fix empty token on swift package-registry login (Issue swiftlang#7453) (swiftlang#7454)
Fix empty token when adding a new package-registry and adding token
interactively on release builds
### Motivation:
When executing swift package-registry login it asks for a token but
fails to retrieve it properly. It sends an empty string to the registry
server and login therefore fails. (see
swiftlang#7453)
### Modifications:
I've debugged the code a bit and found out, that somehow `buffer` and
`passwordPtr` don't seem to be holding correct values after the
`readpassphrase` call.
- An easy quick fix is to make sure that `buffer` doesn't get
deallocated by adding smth like `_ = buffer` after the String init. This
works but is not nice.
- My first try was to use `buffer` instead of `passwordPtr` to create
the string. These works, but I remember reading somewhere that `&` can
be quite nasty sometimes.
- I also tried `buffer.withUnsafeMutablePointer`. However
`readpassphrase` seems to not only change the content of `buffer` but
move it. This leads to a runtime failure `Fatal error: Array
withUnsafeMutableBufferPointer: replacing the buffer is not allowed`
### Result:
The buffer is retained, the token is properly parsed and sent to the
server.
(cherry picked from commit d8c8d0f)1 parent 49e47f9 commit 96cf7f5
File tree
1 file changed
+5
-4
lines changed- Sources/PackageRegistryCommand
1 file changed
+5
-4
lines changedLines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | | - | |
73 | | - | |
| 76 | + | |
74 | 77 | | |
75 | | - | |
76 | | - | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
0 commit comments