Commit 490d0c9ceab25b57006b96cd3a4a3cbb95350c7b

Patrick Steinhardt 2020-06-15T14:26:13

diff_print: return out-of-memory situation when printing binary We currently don't check for out-of-memory situations on exiting `format_binary` and, as a result, may return a partially filled buffer. Fix this by checking the buffer via `git_buf_oom`.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/diff_print.c b/src/diff_print.c
index afe2efa..1ef0f1d 100644
--- a/src/diff_print.c
+++ b/src/diff_print.c
@@ -491,6 +491,9 @@ static int format_binary(
 	}
 	git_buf_putc(pi->buf, '\n');
 
+	if (git_buf_oom(pi->buf))
+		return -1;
+
 	return 0;
 }