summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2020-10-30 09:02:35 (GMT)
committerJan Niklas Hasse <jhasse@bixense.com>2020-10-30 09:02:35 (GMT)
commitd45ff8ebf88ef4add46a80ccdfc2d97a8b4b091b (patch)
tree2019ea1bf10281cb0ed17c0715e13d15ca638192
parent8323cf108f88d582d1f0ced0f44d266e0cd03c3a (diff)
downloadNinja-d45ff8ebf88ef4add46a80ccdfc2d97a8b4b091b.zip
Ninja-d45ff8ebf88ef4add46a80ccdfc2d97a8b4b091b.tar.gz
Ninja-d45ff8ebf88ef4add46a80ccdfc2d97a8b4b091b.tar.bz2
Check return value of setvbuf, fix #509
-rw-r--r--src/build_log.cc4
-rw-r--r--src/deps_log.cc4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/build_log.cc b/src/build_log.cc
index 0a2fac6..04409c8 100644
--- a/src/build_log.cc
+++ b/src/build_log.cc
@@ -190,7 +190,9 @@ bool BuildLog::OpenForWriteIfNeeded() {
if (!log_file_) {
return false;
}
- setvbuf(log_file_, NULL, _IOLBF, BUFSIZ);
+ if (setvbuf(log_file_, NULL, _IOLBF, BUFSIZ) != 0) {
+ return false;
+ }
SetCloseOnExec(fileno(log_file_));
// Opening a file in append mode doesn't set the file pointer to the file's
diff --git a/src/deps_log.cc b/src/deps_log.cc
index 0567c95..191f300 100644
--- a/src/deps_log.cc
+++ b/src/deps_log.cc
@@ -413,7 +413,9 @@ bool DepsLog::OpenForWriteIfNeeded() {
}
// Set the buffer size to this and flush the file buffer after every record
// to make sure records aren't written partially.
- setvbuf(file_, NULL, _IOFBF, kMaxRecordSize + 1);
+ if (setvbuf(file_, NULL, _IOFBF, kMaxRecordSize + 1) != 0) {
+ return false;
+ }
SetCloseOnExec(fileno(file_));
// Opening a file in append mode doesn't set the file pointer to the file's