Commit b1e2ba275ad6089d7247fa02ddfcfcf14eb9a459

Vicent Martí 2012-05-08T23:43:52

message: Proper OOM handling

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/message.c b/src/message.c
index 94745ea..1955557 100644
--- a/src/message.c
+++ b/src/message.c
@@ -42,13 +42,12 @@ int git_message_prettify(git_buf *message_out, const char *message, int strip_co
 		}
 
 		if (consecutive_empty_lines > 0 && message_out->size > 0)
-			if (git_buf_putc(message_out, '\n') < 0)
-				return -1;
+			git_buf_putc(message_out, '\n');
 
 		consecutive_empty_lines = 0;
 		git_buf_put(message_out, message + i, rtrimmed_line_length);
 		git_buf_putc(message_out, '\n');
 	}
 
-	return 0;
+	return git_buf_oom(message_out) ? -1 : 0;
 }