Commit 5147ab56656886e9586f4fc3ad84e1d1e56f3a11

Stefan Sperling 2020-01-29T13:11:45

prevent a NULL deref in gw_get_commits()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index e17fd09..afa9545 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -1912,8 +1912,10 @@ gw_get_commits(struct gw_trans * gw_trans, struct gw_header *header,
 		error = gw_get_commit(gw_trans, header);
 		if (limit > 1) {
 			struct gw_header *n_header = NULL;
-			if ((n_header = gw_init_header()) == NULL)
+			if ((n_header = gw_init_header()) == NULL) {
 				error = got_error_from_errno("malloc");
+				goto done;
+			}
 
 			n_header->refs_str = strdup(header->refs_str);
 			n_header->commit_id = strdup(header->commit_id);