         #endif
 
         var serverinfo: UnsafeMutablePointer<addrinfo>? = nil
+
+        defer {
+            if serverinfo != nil {
+                freeaddrinfo(serverinfo)
+            }
+        }
 
         let status = getaddrinfo(hostname, port.description, &hints, &serverinfo)
 


    func read() -> Data {
        var data = Data()
        let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 65_507)
        var readFlags: Int32 = 0
        buffer.initialize(to: 0x0)
        var read = 0

            data.append(buffer, count: read)
        }

        defer {
            buffer.deallocate(capacity: 4096)
        }
        return data
    }

