diff --git a/Libraries/WebSocket/RCTSRWebSocket.m b/Libraries/WebSocket/RCTSRWebSocket.m index 8ce6edc4dae216..50983c9e303893 100644 --- a/Libraries/WebSocket/RCTSRWebSocket.m +++ b/Libraries/WebSocket/RCTSRWebSocket.m @@ -782,6 +782,10 @@ - (void)_disconnect - (void)_handleFrameWithData:(NSData *)frameData opCode:(NSInteger)opcode { + // copy frameData before handling, + // to avoid concurrent updates to the value at the pointer + frameData = [frameData copy]; + // Check that the current data is valid UTF8 BOOL isControlFrame = (opcode == RCTSROpCodePing || opcode == RCTSROpCodePong || opcode == RCTSROpCodeConnectionClose);