mirror of
https://github.com/google/googletest.git
synced 2026-07-30 08:16:27 +08:00
Merge pull request #5039 from alvinjaison:fix/premature-exit-file-null-deref
PiperOrigin-RevId: 952921022 Change-Id: Ic7c587ad76eb56a9995043c86ee09c64afd52504
This commit is contained in:
commit
a503186d79
@ -5172,9 +5172,12 @@ class ScopedPrematureExitFile {
|
||||
// create the file with a single "0" character in it. I/O
|
||||
// errors are ignored as there's nothing better we can do and we
|
||||
// don't want to fail the test because of this.
|
||||
FILE* pfile = posix::FOpen(premature_exit_filepath_.c_str(), "w");
|
||||
fwrite("0", 1, 1, pfile);
|
||||
fclose(pfile);
|
||||
if (FILE* pfile = posix::FOpen(premature_exit_filepath_.c_str(), "w")) {
|
||||
fwrite("0", 1, 1, pfile);
|
||||
fclose(pfile);
|
||||
} else {
|
||||
premature_exit_filepath_.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5192,7 +5195,7 @@ class ScopedPrematureExitFile {
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string premature_exit_filepath_;
|
||||
std::string premature_exit_filepath_;
|
||||
|
||||
ScopedPrematureExitFile(const ScopedPrematureExitFile&) = delete;
|
||||
ScopedPrematureExitFile& operator=(const ScopedPrematureExitFile&) = delete;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user