Commit Diff


commit - 27d434c2f27987c4eda331b3ab039198ccd6e101
commit + 60f50a586ee410f07b141d9940434644c15c9faa
blob - 5355fad9d12d6460d05da51f01fa125cc0e99ff7
blob + c412692a0b16da6620136e1f5667f7aede401bd6
--- lib/diff.c
+++ lib/diff.c
@@ -440,7 +440,7 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 		const struct got_tree_entries *entries;
 		entries = got_object_tree_get_entries(tree1);
 		te1 = SIMPLEQ_FIRST(&entries->head);
-		if (asprintf(&l1, "%s%s%s", label1, label1[0] ? "/" : "",
+		if (te1 && asprintf(&l1, "%s%s%s", label1, label1[0] ? "/" : "",
 		    te1->name) == -1)
 			return got_error_from_errno();
 	}
@@ -448,7 +448,7 @@ got_diff_tree(struct got_tree_object *tree1, struct go
 		const struct got_tree_entries *entries;
 		entries = got_object_tree_get_entries(tree2);
 		te2 = SIMPLEQ_FIRST(&entries->head);
-		if (asprintf(&l2, "%s%s%s", label2, label2[0] ? "/" : "",
+		if (te2 && asprintf(&l2, "%s%s%s", label2, label2[0] ? "/" : "",
 		    te2->name) == -1)
 			return got_error_from_errno();
 	}