summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-04-29 11:52:45 -0400
committerBrad King <brad.king@kitware.com>2022-04-29 11:56:59 -0400
commit71ded12a756e78bdfe07f54dd84dbfebc7556f09 (patch)
treef0861e7890fe6562294645abfcfce61f76131c35 /Source
parenta8c8842101b45370183eba6294b0178bc2abe55b (diff)
downloadcmake-71ded12a756e78bdfe07f54dd84dbfebc7556f09.tar.gz
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
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratedFileStream.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index c86001a641..a52e66a127 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;
}