Skip to content

Commit 3cf8a45

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
Merge pull request #2184 from dscho/address-coverity-report
Fix some issues reported by Coverity
2 parents 0a07ab2 + d9cbc41 commit 3cf8a45

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

builtin/bisect--helper.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,10 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
571571
write_file(git_path_bisect_start(), "%s\n", start_head.buf);
572572

573573
if (no_checkout) {
574-
get_oid(start_head.buf, &oid);
574+
if (get_oid(start_head.buf, &oid) < 0) {
575+
retval = error(_("invalid ref: '%s'"), start_head.buf);
576+
goto finish;
577+
}
575578
if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0,
576579
UPDATE_REFS_MSG_ON_ERR)) {
577580
retval = -1;

builtin/rebase--interactive.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ static int get_revision_ranges(const char *upstream, const char *onto,
3333
const char *shortrev;
3434
struct object_id rev_oid;
3535

36-
get_oid(base_rev, &rev_oid);
36+
if (get_oid(base_rev, &rev_oid) < 0)
37+
return error(_("invalid rev '%s'"), base_rev);
3738
shortrev = find_unique_abbrev(&rev_oid, DEFAULT_ABBREV);
3839

3940
*shortrevisions = xstrfmt("%s..%s", shortrev, shorthead);

builtin/rebase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ static int rebase_config(const char *var, const char *value, void *data)
848848
if (git_config_bool(var, value))
849849
opts->flags |= REBASE_DIFFSTAT;
850850
else
851-
opts->flags &= !REBASE_DIFFSTAT;
851+
opts->flags &= ~REBASE_DIFFSTAT;
852852
return 0;
853853
}
854854

sequencer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4884,7 +4884,8 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
48844884
struct object_id oid;
48854885
struct stat st;
48864886

4887-
get_oid(onto, &oid);
4887+
if (get_oid(onto, &oid) < 0)
4888+
return error(_("invalid rev: '%s'"), onto);
48884889
shortonto = find_unique_abbrev(&oid, DEFAULT_ABBREV);
48894890

48904891
if (!lstat(todo_file, &st) && st.st_size == 0 &&

0 commit comments

Comments
 (0)