File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -137,8 +137,9 @@ extension Socket {
137
137
138
138
case AF_UNIX:
139
139
var sockaddr_un = try sockaddr_un. make ( from: addr)
140
- return . unix( String ( cString: & sockaddr_un. sun_path. 0 ) )
141
-
140
+ return withUnsafePointer ( to: & sockaddr_un. sun_path. 0 ) {
141
+ return . unix( String ( cString: $0) )
142
+ }
142
143
default :
143
144
throw SocketError . unsupportedAddress
144
145
}
Original file line number Diff line number Diff line change @@ -140,8 +140,11 @@ final class SocketAddressTests: XCTestCase {
140
140
. makeStorage ( )
141
141
142
142
var unix = try sockaddr_un. make ( from: storage)
143
+ let path = withUnsafePointer ( to: & unix. sun_path. 0 ) {
144
+ return String ( cString: $0)
145
+ }
143
146
XCTAssertEqual (
144
- String ( cString : & unix . sun_path . 0 ) ,
147
+ path ,
145
148
" /var "
146
149
)
147
150
}
You can’t perform that action at this time.
0 commit comments