summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNelson Elhage <nelhage@nelhage.com>2018-07-22 23:31:19 +0000
committerPatrick Steinhardt <ps@pks.im>2018-10-26 14:58:51 +0200
commit9023f8f66a4dc03597e75a7527f603cc106c16f7 (patch)
treea045882708de1bc8a06d9fa2ab0898c4cb7500fe
parente129540060d7461679f6ec340d69fb41a4f58118 (diff)
downloadlibgit2-9023f8f66a4dc03597e75a7527f603cc106c16f7.tar.gz
config_file: Don't crash on options without a section
(cherry picked from commit c4d7fa951acd066fd80d83954dd6082c1c7e9e1e)
-rw-r--r--src/config_file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/config_file.c b/src/config_file.c
index 0f4eb0e28..c95ad6705 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -1075,6 +1075,10 @@ static int read_on_variable(
GIT_UNUSED(line);
GIT_UNUSED(line_len);
+ if (!current_section) {
+ giterr_set(GITERR_CONFIG, "no section for key: %s", var_name);
+ return -1;
+ }
git__strtolower(var_name);
git_buf_printf(&buf, "%s.%s", current_section, var_name);
git__free(var_name);