diff options
author | Brad King <brad.king@kitware.com> | 2022-04-29 15:52:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-04-29 15:56:59 (GMT) |
commit | 71ded12a756e78bdfe07f54dd84dbfebc7556f09 (patch) | |
tree | f0861e7890fe6562294645abfcfce61f76131c35 /Source/cmGeneratedFileStream.cxx | |
parent | a8c8842101b45370183eba6294b0178bc2abe55b (diff) | |
download | CMake-71ded12a756e78bdfe07f54dd84dbfebc7556f09.zip CMake-71ded12a756e78bdfe07f54dd84dbfebc7556f09.tar.gz CMake-71ded12a756e78bdfe07f54dd84dbfebc7556f09.tar.bz2 |
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/cmGeneratedFileStream.cxx')
-rw-r--r-- | Source/cmGeneratedFileStream.cxx | 4 |
1 files changed, 3 insertions, 1 deletions
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; } |