repo-config: give value_ a sane default so regexec won't segfault
Signed-off-by: Jonas Fonseca <fonseca@diku.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jonas Fonseca committed
Mar 6, 2006 at 06:23 UTC
f067a13745fbeae1aa357876348a00e5edd0a629
2 files changed
+12
-1
repo-config.c
+4
-1
@@ -14,6 +14,9 @@ static enum { T_RAW, T_INT, T_BOOL } type = T_RAW;
14
15
static int show_config(const char* key_, const char* value_)
16
{
17
+ if (value_ == NULL)
18
+ value_ = "";
19
+
20
if (!strcmp(key_, key) &&
21
(regexp == NULL ||
22
(do_not_match ^
@@ -35,7 +38,7 @@ static int show_config(const char* key_, const char* value_)
38
sprintf(value, "%s", git_config_bool(key_, value_)
39
? "true" : "false");
40
} else {
38
- value = strdup(value_ ? value_ : "");
41
+ value = strdup(value_);
42
}
43
seen++;
44
}
t/t1300-repo-config.sh
+8
@@ -247,5 +247,13 @@ EOF
247
248
test_expect_success 'hierarchical section value' 'cmp .git/config expect'
249
250
+cat > .git/config << EOF
251
+[novalue]
252
+ variable
253
+EOF
254
+
255
+test_expect_success 'get variable with no value' \
256
+ 'git-repo-config --get novalue.variable ^$'
257
+
258
test_done
259