Skip to content

Commit 5f7a334

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

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
@@ -1395,6 +1395,11 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b
13951395
goto done;
13961396
} else {
13971397
head_commit = lookup_commit(the_repository, &info->b_commit);
1398+
if (!head_commit) {
1399+
ret = error(_("could not look up commit '%s'"),
1400+
oid_to_hex (&info->b_commit));
1401+
goto done;
1402+
}
13981403
}
13991404

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

0 commit comments

Comments
 (0)