From 35910439f728c66f5ac00b8f81f2d11810891f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Tue, 8 Oct 2024 22:25:16 +0200 Subject: [PATCH 1/2] do not force unwrap Revert a change from #d2bd7f1aae1fc9455b208567ba5d85e42463c82c that caused the plugin to crash --- Plugins/AWSLambdaPackager/PluginUtils.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/AWSLambdaPackager/PluginUtils.swift b/Plugins/AWSLambdaPackager/PluginUtils.swift index 11827200..0cc3b5fe 100644 --- a/Plugins/AWSLambdaPackager/PluginUtils.swift +++ b/Plugins/AWSLambdaPackager/PluginUtils.swift @@ -32,7 +32,7 @@ struct Utils { let fd = dup(1) let stdout = fdopen(fd, "rw") - defer { fclose(stdout!) } + defer { fclose(stdout) } // We need to use an unsafe transfer here to get the fd into our Sendable closure. // This transfer is fine, because we write to the variable from a single SerialDispatchQueue here. From c71369c8b1d3afb11364ded372a62d6413c5d856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Wed, 9 Oct 2024 10:25:54 +0200 Subject: [PATCH 2/2] test stdout for nil --- Plugins/AWSLambdaPackager/PluginUtils.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/AWSLambdaPackager/PluginUtils.swift b/Plugins/AWSLambdaPackager/PluginUtils.swift index 0cc3b5fe..e12e09dd 100644 --- a/Plugins/AWSLambdaPackager/PluginUtils.swift +++ b/Plugins/AWSLambdaPackager/PluginUtils.swift @@ -32,7 +32,7 @@ struct Utils { let fd = dup(1) let stdout = fdopen(fd, "rw") - defer { fclose(stdout) } + defer { if let so = stdout { fclose(so) } } // We need to use an unsafe transfer here to get the fd into our Sendable closure. // This transfer is fine, because we write to the variable from a single SerialDispatchQueue here.