mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
Resolve static check warnings in example code
Using cppcheck on libgit2 sources indicated two warnings in example code. merge.c was reported as having a memory leak. Fix applied was to `free()` memory pointed to by `parents`. init.c was reported as having a null pointer dereference on variable arg. Function 'usage' was being called with a null variable. Changed supplied parameter to empty string.
This commit is contained in:
@@ -244,5 +244,5 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (!o->dir)
|
||||
usage("must specify directory to init", NULL);
|
||||
usage("must specify directory to init", "");
|
||||
}
|
||||
|
||||
@@ -220,6 +220,7 @@ static int create_merge_commit(git_repository *repo, git_index *index, merge_opt
|
||||
check_lg2(git_repository_head(&head_ref, repo), "failed to get repo HEAD", NULL);
|
||||
if (resolve_refish(&merge_commit, repo, opts->heads[0])) {
|
||||
fprintf(stderr, "failed to resolve refish %s", opts->heads[0]);
|
||||
free(parents);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user