Merge pull request #5039 from alvinjaison:fix/premature-exit-file-null-deref

PiperOrigin-RevId: 952921022
Change-Id: Ic7c587ad76eb56a9995043c86ee09c64afd52504
This commit is contained in:
Copybara-Service 2026-07-23 13:21:28 -07:00
commit a503186d79

View File

@ -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");
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;