Commit 1b3893a25b982a0bd7329a9da23581024c6ac50d

Stefan Sperling 2019-03-18T16:58:14

prevent free with bogus pointer in 'got log' error path

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/got/got.c b/got/got.c
index c32eb50..631c010 100644
--- a/got/got.c
+++ b/got/got.c
@@ -781,6 +781,8 @@ cmd_log(int argc, char *argv[])
 	const char *errstr;
 	struct got_reflist_head refs;
 
+	SIMPLEQ_INIT(&refs);
+
 #ifndef PROFILE
 	if (pledge("stdio rpath wpath cpath flock proc exec sendfd unveil",
 	    NULL)
@@ -940,7 +942,6 @@ cmd_log(int argc, char *argv[])
 		path = in_repo_path;
 	}
 
-	SIMPLEQ_INIT(&refs);
 	error = got_ref_list(&refs, repo);
 	if (error)
 		goto done;