Skip to content

Commit 5964f40

Browse files
committed
Fix crash when writing to a closed TCP client
1 parent 6bd2bfd commit 5964f40

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

AirMessage/Connection/Direct/ClientConnectionTCP.swift

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ class ClientConnectionTCP: ClientConnection {
113113
*/
114114
@discardableResult
115115
func write(data: Data, isEncrypted: Bool) -> Bool {
116+
//Make sure this client is still running
117+
guard isRunning.value else { return false }
118+
116119
//Create the packet structure
117120
var output = Data(capacity: MemoryLayout<Int32>.size + MemoryLayout<Bool>.size + data.count)
118121
withUnsafeBytes(of: Int32(data.count).bigEndian) { output.append(contentsOf: $0) }

0 commit comments

Comments
 (0)