Commit 9f42ff692bc2cb443e1aa112484d293022ce3a30

Stefan Sperling 2019-05-13T11:15:16

check malloc failure in collect_commit_logmsg()

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/got/got.c b/got/got.c
index 33f2e98..fd76c15 100644
--- a/got/got.c
+++ b/got/got.c
@@ -2201,6 +2201,8 @@ collect_commit_logmsg(struct got_pathlist_head *commitable_paths, char **logmsg,
 	if (cmdline_log != NULL && strlen(cmdline_log) != 0) {
 		len = strlen(cmdline_log) + 1;
 		*logmsg = malloc(len + 1);
+		if (*logmsg == NULL)
+			return got_error_prefix_errno("malloc");
 		strlcpy(*logmsg, cmdline_log, len);
 		return NULL;
 	}