Commit 6b68ccd6c881df83e78cf8b525ccfa3c0c3c21d0

Stefan Sperling 2019-09-01T13:10:13

prevent theoretical double-free with non-OpenBSD asprintf (found by jasper)

1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/lib/repository.c b/lib/repository.c
index 597eaa8..dbee69b 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -312,6 +312,7 @@ open_repo(struct got_repository *repo, const char *path)
 
 	/* git repository with working tree? */
 	free(repo->path_git_dir);
+	repo->path_git_dir = NULL;
 	if (asprintf(&repo->path_git_dir, "%s/%s", path, GOT_GIT_DIR) == -1) {
 		err = got_error_from_errno("asprintf");
 		goto done;