Commit c560c1f52d2adb8966e2f783ed7d3f0b37117df9

Omar Polo 2022-03-14T13:50:31

don't `goto done' if calloc fails otherwise we call got_repo_close with repo being NULL and segfault there. ok stsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/lib/repository.c b/lib/repository.c
index bea8c8a..83c3cd0 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -664,10 +664,8 @@ got_repo_open(struct got_repository **repop, const char *path,
 		return got_error_from_errno("getrlimit");
 
 	repo = calloc(1, sizeof(*repo));
-	if (repo == NULL) {
-		err = got_error_from_errno("calloc");
-		goto done;
-	}
+	if (repo == NULL)
+		return got_error_from_errno("calloc");
 
 	RB_INIT(&repo->packidx_bloom_filters);
 	TAILQ_INIT(&repo->packidx_paths);