{"thread":{"id":"3579","subject":"[PATCH] repo-config: give value_ a sane default so regexec won't segfault","startedAt":"2006-03-06T05:23:30Z","lastAt":"2006-03-06T05:23:30Z","messageCount":1,"participants":["Jonas Fonseca"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"17230","messageId":"20060306052330.GB6487@diku.dk","threadId":"3579","inReplyTo":null,"subject":"[PATCH] repo-config: give value_ a sane default so regexec won't segfault","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2006-03-06T05:23:30Z","receivedAt":"2006-03-06T05:23:30Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Signed-off-by: Jonas Fonseca <fonseca@diku.dk>\n\n---\n\n repo-config.c          |    5 ++++-\n t/t1300-repo-config.sh |    8 ++++++++\n 2 files changed, 12 insertions(+), 1 deletions(-)\n\n7fcdb6b9c8c75a0c84076b4a0ebc46b4c7383906\ndiff --git a/repo-config.c b/repo-config.c\nindex 9cf6519..c5ebb76 100644\n--- a/repo-config.c\n+++ b/repo-config.c\n@@ -14,6 +14,9 @@ static enum { T_RAW, T_INT, T_BOOL } typ\n \n static int show_config(const char* key_, const char* value_)\n {\n+\tif (value_ == NULL)\n+\t\tvalue_ = \"\";\n+\n \tif (!strcmp(key_, key) &&\n \t\t\t(regexp == NULL ||\n \t\t\t (do_not_match ^\n@@ -35,7 +38,7 @@ static int show_config(const char* key_,\n \t\t\tsprintf(value, \"%s\", git_config_bool(key_, value_)\n \t\t\t\t\t     ? \"true\" : \"false\");\n \t\t} else {\n-\t\t\tvalue = strdup(value_ ? value_ : \"\");\n+\t\t\tvalue = strdup(value_);\n \t\t}\n \t\tseen++;\n \t}\ndiff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh\nindex 207dd3d..ab4dd5c 100755\n--- a/t/t1300-repo-config.sh\n+++ b/t/t1300-repo-config.sh\n@@ -247,5 +247,13 @@ EOF\n \n test_expect_success 'hierarchical section value' 'cmp .git/config expect'\n \n+cat > .git/config << EOF\n+[novalue]\n+\tvariable\n+EOF\n+\n+test_expect_success 'get variable with no value' \\\n+\t'git-repo-config --get novalue.variable ^$'\n+\n test_done\n \n-- \n1.2.4.g9201\n\n-- \nJonas Fonseca\n"}]}