Skip to content

Commit

Permalink
Merge pull request #105 from TheCoordinator/fix_xcode_13_rc
Browse files Browse the repository at this point in the history
Fix strdup optional check
  • Loading branch information
jakeheis committed Sep 17, 2021
2 parents 588c7d0 + bcd476e commit 29a4afd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Sources/SwiftCLI/Task.swift
Expand Up @@ -283,7 +283,10 @@ extension Task {
}

let argv = ([exec] + swiftArgs).map({ $0.withCString(strdup) })
defer { argv.forEach { free($0)} }
defer {
argv.compactMap { $0 }
.forEach { free($0)}
}

var priorDir: String? = nil
if let directory = directory {
Expand All @@ -297,7 +300,9 @@ extension Task {
envp[env.count] = nil
defer {
for pair in envp ..< envp + env.count {
free(UnsafeMutableRawPointer(pair.pointee))
pair.pointee.map {
free(UnsafeMutableRawPointer($0))
}
}
#if swift(>=4.1)
envp.deallocate()
Expand Down

0 comments on commit 29a4afd

Please sign in to comment.