From 58d87e0def9be831da9f9d3ad96bdccfa59982fa Mon Sep 17 00:00:00 2001 From: Dimitri Racordon Date: Wed, 22 Sep 2021 11:48:19 +0200 Subject: [PATCH] Force unwrap the result of 'strdup' --- Sources/LLVM/Module.swift | 4 ++-- Sources/LLVM/TargetMachine.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/LLVM/Module.swift b/Sources/LLVM/Module.swift index 0487dd27..719ae37c 100644 --- a/Sources/LLVM/Module.swift +++ b/Sources/LLVM/Module.swift @@ -292,7 +292,7 @@ extension Module { path.withCString { cString in let mutable = strdup(cString) LLVMPrintModuleToFile(llvm, mutable, &err) - free(mutable) + free(mutable!) } if let err = err { defer { LLVMDisposeMessage(err) } @@ -325,7 +325,7 @@ extension Module { public func emitBitCode(to path: String) throws { let status = path.withCString { cString -> Int32 in let mutable = strdup(cString) - defer { free(mutable) } + defer { free(mutable!) } return LLVMWriteBitcodeToFile(llvm, mutable) } diff --git a/Sources/LLVM/TargetMachine.swift b/Sources/LLVM/TargetMachine.swift index 6c6995c9..3aefce98 100644 --- a/Sources/LLVM/TargetMachine.swift +++ b/Sources/LLVM/TargetMachine.swift @@ -239,7 +239,7 @@ public class TargetMachine { var err: UnsafeMutablePointer? let status = path.withCString { cStr -> LLVMBool in let mutable = strdup(cStr) - defer { free(mutable) } + defer { free(mutable!) } return LLVMTargetMachineEmitToFile(llvm, module.llvm, mutable, type.asLLVM(), &err) } if let err = err, status != 0 {