Commit c4d7fa951acd066fd80d83954dd6082c1c7e9e1e

Nelson Elhage 2018-07-22T23:31:19

config_file: Don't crash on options without a section

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/config_file.c b/src/config_file.c
index ea72648..b46b0ab 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -1035,6 +1035,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_buf_puts(&buf, current_section);
 	git_buf_putc(&buf, '.');
 	for (c = var_name; *c; c++)