summaryrefslogtreecommitdiff
path: root/t/t1300-repo-config.sh
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@elego.de>2012-11-15 18:10:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-11-16 02:12:17 (GMT)
commit962c38eedd931a608b5e675f12a21569d9f4d39f (patch)
treee5c46cb797bf1d26020a9350050d54ce9797e8ac /t/t1300-repo-config.sh
parent889d35899ba64640e47798681ecb34a4be043bad (diff)
downloadgit-962c38eedd931a608b5e675f12a21569d9f4d39f.zip
git-962c38eedd931a608b5e675f12a21569d9f4d39f.tar.gz
git-962c38eedd931a608b5e675f12a21569d9f4d39f.tar.bz2
config: don't segfault when given --path with a missing value
When given a variable without a value, such as '[section] var' and asking git-config to treat it as a path, git_config_pathname returns an error and doesn't modify its output parameter. show_config assumes that the call is always successful and sets a variable to indicate that vptr should be freed. In case of an error however, trying to do this will cause the program to be killed, as it's pointing to memory in the stack. Detect the error and return immediately to avoid freeing or accessing the uninitialed memory in the stack. Signed-off-by: Carlos Martín Nieto <cmn@elego.de> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1300-repo-config.sh')
-rwxr-xr-xt/t1300-repo-config.sh5
1 files changed, 5 insertions, 0 deletions
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index a477453..17272e0 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -803,6 +803,11 @@ test_expect_success NOT_MINGW 'get --path copes with unset $HOME' '
test_cmp expect result
'
+test_expect_success 'get --path barfs on boolean variable' '
+ echo "[path]bool" >.git/config &&
+ test_must_fail git config --get --path path.bool
+'
+
cat > expect << EOF
[quote]
leading = " test"