Commit 6ced7ba8b0a1cecd667313e4e45f51be404f97c8

Stefan Sperling 2019-09-22T13:28:06

avoid a NULL deref in diff_fileindex_tree(); found by jj@ with scan-build

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/lib/fileindex.c b/lib/fileindex.c
index 05c0896..1db1d75 100644
--- a/lib/fileindex.c
+++ b/lib/fileindex.c
@@ -794,7 +794,7 @@ diff_fileindex_tree(struct got_fileindex *fileindex,
 			next = walk_fileindex(fileindex, *ie);
 			if (got_path_is_child((*ie)->path, path, path_len) &&
 			    (entry_name == NULL ||
-			    strcmp(te->name, entry_name) == 0)) {
+			    (te && strcmp(te->name, entry_name) == 0))) {
 				err = cb->diff_old(cb_arg, *ie, path);
 				if (err || entry_name)
 					break;