@@ -2088,6 +2088,7 @@ - (void)doReceive:(CFSocketRef)theSocket
2088
2088
2089
2089
if ([self hasBytesAvailable: theSocket])
2090
2090
{
2091
+ NSData * bufferData = nil ;
2091
2092
ssize_t result;
2092
2093
CFSocketNativeHandle theNativeSocket = CFSocketGetNative (theSocket);
2093
2094
@@ -2121,9 +2122,10 @@ - (void)doReceive:(CFSocketRef)theSocket
2121
2122
{
2122
2123
buf = realloc (buf, result);
2123
2124
}
2124
- theCurrentReceive-> buffer = [[NSData alloc ] initWithBytesNoCopy: buf
2125
+ bufferData = [[NSData alloc ] initWithBytesNoCopy: buf
2125
2126
length: result
2126
2127
freeWhenDone: YES ];
2128
+ theCurrentReceive->buffer = bufferData;
2127
2129
theCurrentReceive->host = host;
2128
2130
theCurrentReceive->port = port;
2129
2131
}
@@ -2155,9 +2157,10 @@ - (void)doReceive:(CFSocketRef)theSocket
2155
2157
{
2156
2158
buf = realloc (buf, result);
2157
2159
}
2158
- theCurrentReceive-> buffer = [[NSData alloc ] initWithBytesNoCopy: buf
2160
+ bufferData = [[NSData alloc ] initWithBytesNoCopy: buf
2159
2161
length: result
2160
2162
freeWhenDone: YES ];
2163
+ theCurrentReceive->buffer = bufferData;
2161
2164
theCurrentReceive->host = host;
2162
2165
theCurrentReceive->port = port;
2163
2166
}
@@ -2167,8 +2170,8 @@ - (void)doReceive:(CFSocketRef)theSocket
2167
2170
}
2168
2171
2169
2172
// Check to see if we need to free our alloc'd buffer
2170
- // If the buffer is non-nil, this means it has taken ownership of the buffer
2171
- if (theCurrentReceive-> buffer == nil )
2173
+ // If bufferData is non-nil, it has taken ownership of the buffer
2174
+ if (bufferData == nil )
2172
2175
{
2173
2176
free (buf);
2174
2177
}
0 commit comments