Commit e208b1953853f27f2de23f429e9518480a2d51e2

Patrick Steinhardt 2019-08-01T13:42:19

tests: config: catch OOM when assembling conditional config When assembling contents of the conditionally including file, we use `git_buf_printf` and `git_buf_puts` without checking for error returns. Add `cl_git_pass` to fix this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/tests/config/conditionals.c b/tests/config/conditionals.c
index 0e629e4..e2c74c1 100644
--- a/tests/config/conditionals.c
+++ b/tests/config/conditionals.c
@@ -22,11 +22,11 @@ void test_config_conditionals__cleanup(void)
 
 static void assert_condition_includes(const char *keyword, const char *path, bool expected)
 {
-	git_config *cfg;
 	git_buf buf = GIT_BUF_INIT;
+	git_config *cfg;
 
-	git_buf_printf(&buf, "[includeIf \"%s:%s\"]\n", keyword, path);
-	git_buf_puts(&buf, "path = other\n");
+	cl_git_pass(git_buf_printf(&buf, "[includeIf \"%s:%s\"]\n", keyword, path));
+	cl_git_pass(git_buf_puts(&buf, "path = other\n"));
 
 	cl_git_mkfile("empty_standard_repo/.git/config", buf.ptr);
 	cl_git_mkfile("empty_standard_repo/.git/other", "[foo]\nbar=baz\n");