Browse Source

Fix detected memory leaks by removing casting and string interpolation.

Jon Shier 9 years ago
parent
commit
bd66637273
3 changed files with 10 additions and 6 deletions
  1. 4 4
      Source/Alamofire.swift
  2. 1 1
      Source/Manager.swift
  3. 5 1
      Tests/ServerTrustPolicyTests.swift

+ 4 - 4
Source/Alamofire.swift

@@ -89,10 +89,10 @@ func URLRequest(
 {
     let mutableURLRequest: NSMutableURLRequest
 
-    if let request = URLString as? NSMutableURLRequest {
-        mutableURLRequest = request
-    } else if let request = URLString as? NSURLRequest {
-        mutableURLRequest = request.URLRequest
+    if URLString.dynamicType == NSMutableURLRequest.self {
+        mutableURLRequest = URLString as! NSMutableURLRequest
+    } else if URLString.dynamicType == NSURLRequest.self {
+        mutableURLRequest = (URLString as! NSURLRequest).URLRequest
     } else {
         mutableURLRequest = NSMutableURLRequest(URL: NSURL(string: URLString.URLString)!)
     }

+ 1 - 1
Source/Manager.swift

@@ -102,7 +102,7 @@ public class Manager {
                     return "Alamofire/\(build)"
                 }()
 
-                return "\(executable)/\(appVersion) (\(bundle); build:\(appBuild); \(osNameVersion)) \(alamofireVersion)"
+                return executable + "/" + appVersion + " (" + bundle + "; build:" + appBuild + "; " + osNameVersion + ") " + alamofireVersion
             }
 
             return "Alamofire"

+ 5 - 1
Tests/ServerTrustPolicyTests.swift

@@ -1422,7 +1422,11 @@ class ServerTrustPolicyCertificatesInBundleTestCase: ServerTrustPolicyTestCase {
         #if os(OSX)
             // For some reason, OSX is allowing all certificates to be considered valid. Need to file a
             // rdar demonstrating this behavior.
-            XCTAssertEqual(certificates.count, 23, "Expected 23 well-formed certificates")
+            if #available(OSX 10.12, *) {
+                XCTAssertEqual(certificates.count, 19, "Expected 19 well-formed certificates")
+            } else {
+                XCTAssertEqual(certificates.count, 23, "Expected 23 well-formed certificates")
+            }
         #else
             XCTAssertEqual(certificates.count, 19, "Expected 19 well-formed certificates")
         #endif