Commit 654cd5ff7b47b1a9ed64d49ad97be509974dde8d

Vicent Marti 2010-12-02T21:50:28

Fix segfault in t0603 (unitialized pointer) Signed-off-by: Vicent Marti <tanoku@gmail.com>

diff --git a/tests/t0603-sort.c b/tests/t0603-sort.c
index 35f7f87..954394f 100644
--- a/tests/t0603-sort.c
+++ b/tests/t0603-sort.c
@@ -43,8 +43,6 @@ BEGIN_TEST(index_sort_test)
 	unsigned int i;
 	git_index_entry **entries;
 
-	entries = (git_index_entry **)index->entries.contents;
-
 	must_pass(git_index_open_bare(&index, TEST_INDEX_PATH));
 	must_pass(git_index_read(index));
 
@@ -53,6 +51,8 @@ BEGIN_TEST(index_sort_test)
 	git_index__sort(index);
 	must_be_true(index->sorted);
 
+	entries = (git_index_entry **)index->entries.contents;
+
 	for (i = 1; i < index->entries.length; ++i)
 		must_be_true(strcmp(entries[i - 1]->path, entries[i]->path) < 0);