Commit 94e30d9b14b96283295b107268a862d37a96894f

Carlos Martín Nieto 2017-10-30T15:55:18

config: check for OOM when writing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/config_file.c b/src/config_file.c
index 73c9000..9a6d815 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -1955,10 +1955,12 @@ static int config_write(diskfile_backend *cfg, const char *orig_key, const char 
 	ldot = strrchr(key, '.');
 	name = ldot + 1;
 	section = git__strndup(key, ldot - key);
+	GITERR_CHECK_ALLOC(section);
 
 	ldot = strrchr(orig_key, '.');
 	orig_name = ldot + 1;
 	orig_section = git__strndup(orig_key, ldot - orig_key);
+	GITERR_CHECK_ALLOC(orig_section);
 
 	write_data.buf = &buf;
 	git_buf_init(&write_data.buffered_comment, 0);