From 27d2b701b44fd970398116b0b2d3d57ffad8745a Mon Sep 17 00:00:00 2001 From: Chun Chen Hsu Date: Fri, 21 Oct 2016 00:35:36 -0400 Subject: [PATCH] Fix bug that causes swift compiler crash This patch unwraps the optional UnsafePointer data before calling withMemoryRebound. This can prevent compiler from crash because somehow calling withMemoryRebound() with an optional UnsafePointer will cause compiler crash which has been reported in https://bugs.swift.org/browse/SR-2668. --- Sources/PerfectHTTPServer/HTTP11Request.swift | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Sources/PerfectHTTPServer/HTTP11Request.swift b/Sources/PerfectHTTPServer/HTTP11Request.swift index b4d0fe3..bcaa6d6 100644 --- a/Sources/PerfectHTTPServer/HTTP11Request.swift +++ b/Sources/PerfectHTTPServer/HTTP11Request.swift @@ -232,10 +232,12 @@ class HTTP11Request: HTTPRequest { self.mimes = MimeReader(contentType) } } - data?.withMemoryRebound(to: UInt8.self, capacity: length) { - data in - for i in 0..