mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-30 11:10:06 -05:00
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
This commit is contained in:
@@ -180,7 +180,9 @@ bool cmGeneratedFileStreamBase::Close()
|
|||||||
// Else, the destination was not replaced.
|
// Else, the destination was not replaced.
|
||||||
//
|
//
|
||||||
// Always delete the temporary file. We never want it to stay around.
|
// 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;
|
return replaced;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user