Commit d1542a279fa71d03ea53283d994b76f9b48824af

Stefan Sperling 2019-02-05T18:24:28

fix endless loop in got_worktree_open()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/lib/worktree.c b/lib/worktree.c
index f4d98f7..6a1ed92 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -403,7 +403,9 @@ got_worktree_open(struct got_worktree **worktree, const char *path)
 		if (*worktree)
 			return NULL;
 		path = dirname(path);
-	} while (path && !(path[0] == '.' && path[1] == '\0'));
+		if (path == NULL)
+			return got_error_from_errno();
+	} while (!((path[0] == '.' || path[0] == '/') && path[1] == '\0'));
 
 	return got_error(GOT_ERR_NOT_WORKTREE);
 }