diff options
author | Colin Cross <ccross@android.com> | 2017-06-16 18:03:51 (GMT) |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2017-06-16 19:51:26 (GMT) |
commit | 11a934d427502f917dbbf47b088d9abde186c0a7 (patch) | |
tree | 5545135e808072f7f6a453264fb3c4d74c6fb210 /src/graph.cc | |
parent | 00f69c17951fee353068c3905b4dd4d08322fdd3 (diff) | |
download | Ninja-11a934d427502f917dbbf47b088d9abde186c0a7.zip Ninja-11a934d427502f917dbbf47b088d9abde186c0a7.tar.gz Ninja-11a934d427502f917dbbf47b088d9abde186c0a7.tar.bz2 |
Fix segfault on edge with no inputs
PR #1281 added a deference of most_recent_input without checking
for NULL, which can occur if a build rule has no inputs.
Check it for null before dereferencing, and add a test.
Fixes #1290.
Diffstat (limited to 'src/graph.cc')
-rw-r--r-- | src/graph.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/graph.cc b/src/graph.cc index 27013d5..c90aaad 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -193,7 +193,7 @@ bool DependencyScan::RecomputeOutputDirty(Edge* edge, EXPLAIN("command line changed for %s", output->path().c_str()); return true; } - if (entry->mtime < most_recent_input->mtime()) { + if (most_recent_input && entry->mtime < most_recent_input->mtime()) { // May also be dirty due to the mtime in the log being older than the // mtime of the most recent input. This can occur even when the mtime // on disk is newer if a previous run wrote to the output file but |