diff options
author | Evan Martin <martine@danga.com> | 2011-05-11 16:58:29 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-05-11 18:29:01 (GMT) |
commit | eccebffca22672b4f9d4c381e38eaad5884c352f (patch) | |
tree | c420e4b6c5189fea6c87d084bef9e23872be9e8c /src/build_log.cc | |
parent | fa8830b546428e1daa829d0ddf2465697e0d9bb3 (diff) | |
download | Ninja-eccebffca22672b4f9d4c381e38eaad5884c352f.zip Ninja-eccebffca22672b4f9d4c381e38eaad5884c352f.tar.gz Ninja-eccebffca22672b4f9d4c381e38eaad5884c352f.tar.bz2 |
don't crash on truncated log files
Add a test that tries all truncations of a log file and verifies it
doesn't crash.
Diffstat (limited to 'src/build_log.cc')
-rw-r--r-- | src/build_log.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/build_log.cc b/src/build_log.cc index cd74bd1..c630fbe 100644 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -144,8 +144,15 @@ bool BuildLog::Load(const string& path, string* err) { } end = strchr(start, ' '); + if (!end) + continue; string output = string(start, end - start); + start = end + 1; + end = strchr(start, '\n'); + if (!end) + continue; + LogEntry* entry; Log::iterator i = log_.find(output); if (i != log_.end()) { @@ -160,9 +167,6 @@ bool BuildLog::Load(const string& path, string* err) { entry->output = output; entry->start_time = start_time; entry->end_time = end_time; - - start = end + 1; - end = strchr(start, '\n'); entry->command = string(start, end - start); } |