Skip to content

Commit 7c690c0

Browse files
committed
stash: defensive programming
CodeQL points out that `lookup_commit()` can return NULL values. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent e9ad531 commit 7c690c0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

builtin/stash.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,11 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
14561456
goto done;
14571457
} else {
14581458
head_commit = lookup_commit(the_repository, &info->b_commit);
1459+
if (!head_commit) {
1460+
ret = error(_("could not look up commit '%s'"),
1461+
oid_to_hex (&info->b_commit));
1462+
goto done;
1463+
}
14591464
}
14601465

14611466
if (!check_changes(ps, include_untracked, &untracked_files)) {

0 commit comments

Comments
 (0)