Check the result of git_buf_joinpath
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
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);