Skip to content

Commit

Permalink
Fix Xcode 12.5 Warning: Write to autoreleasing out parameter inside l…
Browse files Browse the repository at this point in the history
…ocally-scoped autorelease pool
  • Loading branch information
hvbommel committed Apr 29, 2021
1 parent 9f47ef9 commit 2d131ac
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Source/GCD/GCDAsyncSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,7 @@ + (nullable instancetype)socketFromConnectedSocketFD:(int)socketFD delegate:(nul
+ (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
{
__block BOOL errorOccured = NO;
__block NSError *thisError = nil;

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

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

errorOccured = YES;
if (error)
*error = [NSError errorWithDomain:GCDAsyncSocketErrorDomain code:GCDAsyncSocketOtherError userInfo:userInfo];
thisError = [NSError errorWithDomain:GCDAsyncSocketErrorDomain code:GCDAsyncSocketOtherError userInfo:userInfo];
return;
}

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

errorOccured = YES;
if (error)
*error = [NSError errorWithDomain:GCDAsyncSocketErrorDomain code:GCDAsyncSocketOtherError userInfo:userInfo];
thisError = [NSError errorWithDomain:GCDAsyncSocketErrorDomain code:GCDAsyncSocketOtherError userInfo:userInfo];
return;
}

socket->flags = kSocketStarted;
[socket didConnect:socket->stateIndex];
}});

if (error && thisError) {
*error = thisError;
}

return errorOccured? nil: socket;
}

Expand Down

0 comments on commit 2d131ac

Please sign in to comment.