Commit Diff


commit - 7a132809bdab22b3b3e7fa12588930979f19acd5
commit + 621015ac3ab52e480c58727e69a7a7ee4f945699
blob - 21b696a14044185473bf54c97ff7dc48f3a7d678
blob + 7c0bf3a9347605e6349077b56dcef8d15aff3c95
--- got/got.c
+++ got/got.c
@@ -311,7 +311,7 @@ print_commit(struct got_commit_object *commit, struct 
     struct got_repository *repo, int show_patch)
 {
 	const struct got_error *err = NULL;
-	char *id_str, *datestr, *logmsg, *line;
+	char *id_str, *datestr, *logmsg0, *logmsg, *line;
 	char datebuf[26];
 	time_t author_time, committer_time;
 
@@ -349,16 +349,17 @@ print_commit(struct got_commit_object *commit, struct 
 		}
 	}
 
-	logmsg = strdup(commit->logmsg);
-	if (logmsg == NULL)
+	logmsg0 = strdup(commit->logmsg);
+	if (logmsg0 == NULL)
 		return got_error_from_errno();
 
+	logmsg = logmsg0;
 	do {
 		line = strsep(&logmsg, "\n");
 		if (line)
 			printf(" %s\n", line);
 	} while (line);
-	free(logmsg);
+	free(logmsg0);
 
 	if (show_patch) {
 		err = print_patch(commit, id, repo);