diff options
Diffstat (limited to 'src/blame.c')
-rw-r--r-- | src/blame.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/blame.c b/src/blame.c index ea9f77af5..f732338e6 100644 --- a/src/blame.c +++ b/src/blame.c @@ -108,17 +108,23 @@ git_blame* git_blame__alloc( git_blame_options opts, const char *path) { - git_blame *gbr = (git_blame*)git__calloc(1, sizeof(git_blame)); - if (!gbr) { - giterr_set_oom(); + git_blame *gbr = git__calloc(1, sizeof(git_blame)); + if (!gbr) return NULL; - } - git_vector_init(&gbr->hunks, 8, hunk_cmp); - git_vector_init(&gbr->paths, 8, paths_cmp); + gbr->repository = repo; gbr->options = opts; - gbr->path = git__strdup(path); - git_vector_insert(&gbr->paths, git__strdup(path)); + + if (git_vector_init(&gbr->hunks, 8, hunk_cmp) < 0 || + git_vector_init(&gbr->paths, 8, paths_cmp) < 0 || + (gbr->path = git__strdup(path)) == NULL || + git_vector_insert(&gbr->paths, git__strdup(path)) < 0) + { + git_blame_free(gbr); + git__free(gbr); + return NULL; + } + return gbr; } @@ -140,7 +146,7 @@ void git_blame_free(git_blame *blame) git_array_clear(blame->line_index); - git__free((void*)blame->path); + git__free(blame->path); git_blob_free(blame->final_blob); git__free(blame); } |