Commit 07c5dc84fd486b380d618319b4852591d355bd81

Edward Thomson 2013-12-08T12:36:48

Merge pull request #1994 from palistov/commit-cleanup commit: Fix potential segfault

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/commit.c b/src/commit.c
index bbb76f3..4ddfafb 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -276,10 +276,12 @@ GIT_COMMIT_GETTER(const git_oid *, tree_id, &commit->tree_id);
 
 const char *git_commit_message(const git_commit *commit)
 {
-	const char *message = commit->raw_message;
+	const char *message;
 
 	assert(commit);
 
+	message = commit->raw_message;
+
 	/* trim leading newlines from raw message */
 	while (*message && *message == '\n')
 		++message;