Commit cffd616a7205d6b025f3736eb6c0a1ae9c3cd85d

Patrick Steinhardt 2017-03-28T09:08:41

path: handle error returned by `git_buf_joinpath` In the `_check_dir_contents` function, we first allocate memory for joining the directory and subdirectory together and afterwards use `git_buf_joinpath`. While this function in fact should not fail as memory is already allocated, err on the safe side and check for returned errors.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/path.c b/src/path.c
index c3d3eb1..9b15c8c 100644
--- a/src/path.c
+++ b/src/path.c
@@ -700,7 +700,8 @@ static bool _check_dir_contents(
 		return false;
 
 	/* save excursion */
-	git_buf_joinpath(dir, dir->ptr, sub);
+	if (git_buf_joinpath(dir, dir->ptr, sub) < 0)
+		return false;
 
 	result = predicate(dir->ptr);