Commit e759b0721718f99f515997c2e7c9c254b35741af

Edward Thomson 2012-12-12T17:54:12

don't walk off the end of the index

diff --git a/src/index.c b/src/index.c
index 1e5b280..d4568aa 100644
--- a/src/index.c
+++ b/src/index.c
@@ -957,13 +957,14 @@ int git_index_conflict_remove(git_index *index, const char *path)
 			continue;
 		}
 
-		error = git_vector_remove(&index->entries, (unsigned int)pos);
+		if ((error = git_vector_remove(&index->entries, (unsigned int)pos)) < 0)
+			return error;
 
-		if (error >= 0)
-			index_entry_free(conflict_entry);
+		index_entry_free(conflict_entry);
+		posmax--;
 	}
 
-	return error;
+	return 0;
 }
 
 static int index_conflicts_match(const git_vector *v, size_t idx)