From 71ded12a756e78bdfe07f54dd84dbfebc7556f09 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 29 Apr 2022 11:52:45 -0400 Subject: cmGeneratedFileStream: Do not remove empty path If `Close()` is called when a file was never opened, we have no temporary file path. Do not try to remove it. Some implementations of `unlink()` crash on an empty path (though the documented behavior is to fail with `ENOENT`). Fixes: #23414 --- Source/cmGeneratedFileStream.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index c86001a..a52e66a 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -180,7 +180,9 @@ bool cmGeneratedFileStreamBase::Close() // Else, the destination was not replaced. // // Always delete the temporary file. We never want it to stay around. - cmSystemTools::RemoveFile(this->TempName); + if (!this->TempName.empty()) { + cmSystemTools::RemoveFile(this->TempName); + } return replaced; } -- cgit v0.12