Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2021-05-12 23:16:13 +0300
committerJunio C Hamano <gitster@pobox.com>2021-05-13 02:48:59 +0300
commit1ff595d218d9175eee1db753844044c2746d0515 (patch)
treed9d03e88268610d8068991429bab02d7fdfa4dc1 /builtin
parentaa2b05d9f66f5c167a7a377e2a0990f4af835e71 (diff)
stash show: fix segfault with --{include,only}-untracked
When `git stash show --include-untracked` or `git stash show --only-untracked` is run on a stash that doesn't include an untracked entry, a segfault occurs. This happens because we do not check whether the untracked entry is actually present and just attempt to blindly dereference it. Ensure that the untracked entry is present before actually attempting to dereference it. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/stash.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/builtin/stash.c b/builtin/stash.c
index 8922a1240c..82e4829d44 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -900,10 +900,14 @@ static int show_stash(int argc, const char **argv, const char *prefix)
diff_tree_oid(&info.b_commit, &info.w_commit, "", &rev.diffopt);
break;
case UNTRACKED_ONLY:
- diff_root_tree_oid(&info.u_tree, "", &rev.diffopt);
+ if (info.has_u)
+ diff_root_tree_oid(&info.u_tree, "", &rev.diffopt);
break;
case UNTRACKED_INCLUDE:
- diff_include_untracked(&info, &rev.diffopt);
+ if (info.has_u)
+ diff_include_untracked(&info, &rev.diffopt);
+ else
+ diff_tree_oid(&info.b_commit, &info.w_commit, "", &rev.diffopt);
break;
}
log_tree_diff_flush(&rev);