From f4221bc281e34e3171ba8bc4b1e49d1f53aaf118 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 24 Jan 2025 08:37:42 +0100 Subject: Delete target file if generating tool fails, ensuring no half written/corrupted files are left on disk. --- src/task_cc.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/task_cc.cc') diff --git a/src/task_cc.cc b/src/task_cc.cc index cd2b51c..b9edcf7 100644 --- a/src/task_cc.cc +++ b/src/task_cc.cc @@ -192,7 +192,13 @@ int TaskCC::runInner() } const auto& cfg = ctor::get_configuration(); - return execute(settings, compiler(), args, cfg.env); + auto res = execute(settings, compiler(), args, cfg.env); + if(res != 0) + { + std::filesystem::remove(targetFile()); + } + + return res; } int TaskCC::clean() -- cgit v1.2.3