Skip to content

Commit abba7ee

Browse files
dschogitster
authored andcommitted
push: defensive programming
CodeQL points out that `branch_get()` can return NULL values. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5f7a334 commit abba7ee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static void refspec_append_mapped(struct refspec *refspec, const char *ref,
9090
if (push_default == PUSH_DEFAULT_UPSTREAM &&
9191
skip_prefix(matched->name, "refs/heads/", &branch_name)) {
9292
struct branch *branch = branch_get(branch_name);
93-
if (branch->merge_nr == 1 && branch->merge[0]->src) {
93+
if (branch && branch->merge_nr == 1 && branch->merge[0]->src) {
9494
refspec_appendf(refspec, "%s:%s",
9595
ref, branch->merge[0]->src);
9696
return;

0 commit comments

Comments
 (0)