Skip to content

Commit 0cbccd8

Browse files
committed
stash: defensive programming
CodeQL points out that `lookup_commit()` can return NULL values. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 3759357 commit 0cbccd8

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
@@ -1461,6 +1461,11 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
14611461
goto done;
14621462
} else {
14631463
head_commit = lookup_commit(the_repository, &info->b_commit);
1464+
if (!head_commit) {
1465+
ret = error(_("could not look up commit '%s'"),
1466+
oid_to_hex (&info->b_commit));
1467+
goto done;
1468+
}
14641469
}
14651470

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

0 commit comments

Comments
 (0)