Skip to content

Commit 5ddba5e

Browse files
Merge pull request #764 from hvbommel/FixWarnings
Fix Xcode 12.5 Warning: Write to autoreleasing out parameter ...
2 parents 9f47ef9 + 2d131ac commit 5ddba5e

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Source/GCD/GCDAsyncSocket.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,7 @@ + (nullable instancetype)socketFromConnectedSocketFD:(int)socketFD delegate:(nul
10771077
+ (nullable instancetype)socketFromConnectedSocketFD:(int)socketFD delegate:(nullable id<GCDAsyncSocketDelegate>)aDelegate delegateQueue:(nullable dispatch_queue_t)dq socketQueue:(nullable dispatch_queue_t)sq error:(NSError* __autoreleasing *)error
10781078
{
10791079
__block BOOL errorOccured = NO;
1080+
__block NSError *thisError = nil;
10801081

10811082
GCDAsyncSocket *socket = [[[self class] alloc] initWithDelegate:aDelegate delegateQueue:dq socketQueue:sq];
10821083

@@ -1093,8 +1094,7 @@ + (nullable instancetype)socketFromConnectedSocketFD:(int)socketFD delegate:(nul
10931094
NSDictionary *userInfo = @{NSLocalizedDescriptionKey : errMsg};
10941095

10951096
errorOccured = YES;
1096-
if (error)
1097-
*error = [NSError errorWithDomain:GCDAsyncSocketErrorDomain code:GCDAsyncSocketOtherError userInfo:userInfo];
1097+
thisError = [NSError errorWithDomain:GCDAsyncSocketErrorDomain code:GCDAsyncSocketOtherError userInfo:userInfo];
10981098
return;
10991099
}
11001100

@@ -1115,15 +1115,18 @@ + (nullable instancetype)socketFromConnectedSocketFD:(int)socketFD delegate:(nul
11151115
NSDictionary *userInfo = @{NSLocalizedDescriptionKey : errMsg};
11161116

11171117
errorOccured = YES;
1118-
if (error)
1119-
*error = [NSError errorWithDomain:GCDAsyncSocketErrorDomain code:GCDAsyncSocketOtherError userInfo:userInfo];
1118+
thisError = [NSError errorWithDomain:GCDAsyncSocketErrorDomain code:GCDAsyncSocketOtherError userInfo:userInfo];
11201119
return;
11211120
}
11221121

11231122
socket->flags = kSocketStarted;
11241123
[socket didConnect:socket->stateIndex];
11251124
}});
11261125

1126+
if (error && thisError) {
1127+
*error = thisError;
1128+
}
1129+
11271130
return errorOccured? nil: socket;
11281131
}
11291132

0 commit comments

Comments
 (0)