summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2013-04-29 07:36:34 (GMT)
committerNico Weber <nicolasweber@gmx.de>2013-04-29 07:37:48 (GMT)
commit2b26bf2bda4b13e6c560c07e7ab20bf6abfed53e (patch)
tree4f25035dbc02a90598cd7974e8c3fb8b723486bc /src
parent3699cb6aa2fb29125bf725cb50fbcc593da8a8a1 (diff)
downloadNinja-2b26bf2bda4b13e6c560c07e7ab20bf6abfed53e.zip
Ninja-2b26bf2bda4b13e6c560c07e7ab20bf6abfed53e.tar.gz
Ninja-2b26bf2bda4b13e6c560c07e7ab20bf6abfed53e.tar.bz2
Don't crash during deps log recompaction if there's more than one deps entry.
Part of issue #554.
Diffstat (limited to 'src')
-rw-r--r--src/deps_log.cc2
-rw-r--r--src/deps_log_test.cc6
2 files changed, 8 insertions, 0 deletions
diff --git a/src/deps_log.cc b/src/deps_log.cc
index c52503b..5ecdeef 100644
--- a/src/deps_log.cc
+++ b/src/deps_log.cc
@@ -257,6 +257,8 @@ bool DepsLog::Recompact(const string& path, string* err) {
// Write out all deps again.
for (int old_id = 0; old_id < (int)deps_.size(); ++old_id) {
Deps* deps = deps_[old_id];
+ if (!deps) continue; // If nodes_[old_id] is a leaf, it has no deps.
+
if (!new_log.RecordDeps(nodes_[old_id], deps->mtime,
deps->node_count, deps->nodes)) {
new_log.Close();
diff --git a/src/deps_log_test.cc b/src/deps_log_test.cc
index 9623d17..ac4bdeb 100644
--- a/src/deps_log_test.cc
+++ b/src/deps_log_test.cc
@@ -137,6 +137,12 @@ TEST_F(DepsLogTest, Recompact) {
deps.push_back(state.GetNode("foo.h"));
deps.push_back(state.GetNode("bar.h"));
log.RecordDeps(state.GetNode("out.o"), 1, deps);
+
+ deps.clear();
+ deps.push_back(state.GetNode("foo.h"));
+ deps.push_back(state.GetNode("baz.h"));
+ log.RecordDeps(state.GetNode("other_out.o"), 1, deps);
+
log.Close();
struct stat st;