Commit 3dbd9a0e86f30e1192fd76ce98c9fbce1801a1d9

Jacques Germishuys 2014-12-24T11:43:38

Check the result of git_buf_joinpath

diff --git a/src/rebase.c b/src/rebase.c
index 0c84a48..ceb74d3 100644
--- a/src/rebase.c
+++ b/src/rebase.c
@@ -592,7 +592,8 @@ static int rebase_init(
 	git_buf state_path = GIT_BUF_INIT;
 	int error;
 
-	git_buf_joinpath(&state_path, repo->path_repository, REBASE_MERGE_DIR);
+	if ((error = git_buf_joinpath(&state_path, repo->path_repository, REBASE_MERGE_DIR)) < 0)
+		return error;
 
 	rebase->repo = repo;
 	rebase->type = GIT_REBASE_TYPE_MERGE;
diff --git a/src/repository.c b/src/repository.c
index 74a966e..0cf8eb6 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -656,7 +656,8 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
 		git_buf odb_path = GIT_BUF_INIT;
 		git_odb *odb;
 
-		git_buf_joinpath(&odb_path, repo->path_repository, GIT_OBJECTS_DIR);
+		if ((error = git_buf_joinpath(&odb_path, repo->path_repository, GIT_OBJECTS_DIR)) < 0)
+			return error;
 
 		error = git_odb_open(&odb, odb_path.ptr);
 		if (!error) {
@@ -741,7 +742,8 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo)
 		git_buf index_path = GIT_BUF_INIT;
 		git_index *index;
 
-		git_buf_joinpath(&index_path, repo->path_repository, GIT_INDEX_FILE);
+		if ((error = git_buf_joinpath(&index_path, repo->path_repository, GIT_INDEX_FILE)) < 0)
+			return error;
 
 		error = git_index_open(&index, index_path.ptr);
 		if (!error) {
@@ -2068,7 +2070,9 @@ int git_repository_is_shallow(git_repository *repo)
 	struct stat st;
 	int error;
 
-	git_buf_joinpath(&path, repo->path_repository, "shallow");
+	if ((error = git_buf_joinpath(&path, repo->path_repository, "shallow")) < 0)
+		return error;
+
 	error = git_path_lstat(path.ptr, &st);
 	git_buf_free(&path);