Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make copying optional when receiving data #428

Merged
merged 10 commits into from
Oct 31, 2016
14 changes: 7 additions & 7 deletions SocketRocket/SRWebSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -791,19 +791,19 @@ - (void)closeConnection;

- (void)_handleFrameWithData:(NSData *)frameData opCode:(NSInteger)opcode;
{
//frameData will be copied before passing to handlers
//otherwise there can be misbehaviours when value at the pointer is changed
frameData = [frameData copy];

// Check that the current data is valid UTF8

BOOL isControlFrame = (opcode == SROpCodePing || opcode == SROpCodePong || opcode == SROpCodeConnectionClose);
if (!isControlFrame) {
[self _readFrameNew];
} else {
if (isControlFrame) {
//frameData will be copied before passing to handlers
//otherwise there can be misbehaviours when value at the pointer is changed
frameData = [frameData copy];

dispatch_async(_workQueue, ^{
[self _readFrameContinue];
});
} else {
[self _readFrameNew];
}

switch (opcode) {
Expand Down